Assigning Values to an Array: Difference between revisions

Content added Content deleted
Line 61: Line 61:
To put an item on the end of a list:
To put an item on the end of a list:
set end of array to item
set end of array to item

=={{header|AWK}}==
In the first example, a["hello"] is overwritten; in the second, a["hellx"] is not added.
<lang awk>
$ awk 'BEGIN{a["hello"]="salut";if("hello" in a)a["hello"]="bonjour";for(i in a)print i,a[i]}'
hello bonjour

$ awk 'BEGIN{a["hello"]="salut";if("hellx" in a)a["hellx"]="bonjour";for(i in a)print i,a[i]}'
hello salut
</lang>


=={{header|Brainf***}}==
=={{header|Brainf***}}==