Slides
Next: Arrays >>

Collections

  • Arrays
  • Hashes
  • Ranges

Ref. WGR Chapter 9, Collection and container objects

Array vs. Hash

Array Hash
ordered list of values unordered set of key/value pairs
has an index that must be an integer has a key that can be any object
(symbol, number, string, another hash, etc.)
also called List, Vector, Stack(?) Hash is also called Map, Dictionary
literals are defined with [ ] literals are defined with { }
accessed with [ ] also accessed with [ ]
comments powered by Disqus