308
edits
m (Grammar. Getting late, is it? ;-) |
(added iterating hash documentation and example) |
||
Line 623: | Line 623: | ||
This is what most Nasal code using OOP will typically look like. | This is what most Nasal code using OOP will typically look like. | ||
== Hashes and foreach (enumerating a hash) == | |||
To iterate through all elements in a hash the keys(hash) method is used to produce a vector of the keys for the hash. | |||
<syntaxhighlight lang="nasal"> | |||
var namehash = {}; | |||
namehash["value1"]= 1; | |||
namehash["value2"] =2; | |||
foreach(var hash_key ; keys(namehash)) | |||
print(namehash[hash_key]); | |||
</syntaxhighlight> | |||
== A generic constructor == | == A generic constructor == |
edits