You are viewing a single comment's thread from:

RE: My Notes on Wren, the Language of EOS

in #eos8 years ago

great job with this wren overview! just one thing that stood out...

Don't expect things to print in some rational order. This has tripped me up before with languages like JavaScript as well.

The reason the ordering seems random and strange is that you are using a HashMap versus an Array or List.

Array:
[0] -> {"Arizona": "Cactus wren"}
[1] -> {"Hawaii": "Nēnē"}
[2] -> {"Ohio": "Northern Cardinal"}

HashMap:
keyHash(Hawaii) -> [0] -> {"Hawaii": "Nēnē"}
keyHash(Ohio) -> [1] -> {"Ohio": "Northern Cardinal"}
keyHash(Arizona) -> [2] -> {"Arizona": "Cactus wren"}
(array hash position may also change depending on how many buckets are available to the hash table)

It's pretty much the same across all languages. For example, here's an explanation of the differences and syntax in Java: "Difference between ArrayList and HashMap in Java"

and in wren, you've also got lists and maps.