Assigning Values to an Array: Difference between revisions
Content added Content deleted
(→{{header|Brainf***}}: + AWK) |
(→{{header|AWK}}: + error raising) |
||
Line 71: | Line 71: | ||
hello salut |
hello salut |
||
</lang> |
</lang> |
||
The above code does not raise an error if the array element does not exist. |
|||
I am not sure how to raise a deliberate error in awk, but 1/0 comes in handy, if really required: |
|||
<lang AWK>$ awk 'BEGIN{a["hello"]="salut";if("hellx" in a)a["hellx"]="bonjour";else 1/0;for(i in a)print i,a[i]}' |
|||
awk: cmd. line:1: fatal: division by zero attempted</lang> |
|||
=={{header|Brainf***}}== |
=={{header|Brainf***}}== |