Arrays: Difference between revisions

Content added Content deleted
Line 3,857: Line 3,857:
=={{header|Oforth}}==
=={{header|Oforth}}==


Array created with [ ... ] are immutable array.
Oforth has no Array class.
To create a mutable array, #new is used.
Lists are immutables and can act like arrays.
To have a mutable array, a ListBuffer can be used.


<lang Oforth>[ "abd", "def", "ghi" ] at(3) println
<lang Oforth>[ "abd", "def", "ghi" ] at( 3 ) .


ListBuffer new dup addAll([1, 2, 3]) dup put(2, 8.1) println
Array new dup addAll( [1, 2, 3] ) dup put( 2, 8.1 ) .
</lang>
</lang>