ANN map-1.4.0

NAME
map.rb

SYNOPSIS
the ruby container you’ve always wanted: a string/symbol indifferent
ordered
hash that works in all rubies

INSTALL
gem install map

URI
http://github.com/ahoward/map

DESCRIPTION

maps are ordered. constructing them in an ordered fashion builds

them that

way

m = Map[:k, :v, :key, :val]
m = Map(:k, :v, :key, :val)

m = Map[[:k, :v], [:key, :val]]
m = Map[{:k => :v, :key => :val}]

m = Map.new
m[:a] = 0
m[:b] = 1
m[:c] = 2

p m.keys #=> [‘a’,‘b’,‘c’] ### always ordered!
p m.values #=> [0,1,2] ### always ordered!

maps don’t care between symbol and string keys

p m[:a] #=> 0
p m[“a”] #=> 0

many functions operate in a way one would expect from an ordered

container

m.update(:k2 => :v2)
m.update(:k2, :v2)

maps keep mapiness for even deep operations

m.update :nested => {:hashes => {:are => :converted}}

maps can give back clever little struct objects

m = Map(:foo => {:bar => 42})
s = m.struct
p s.foo.bar #=> 42

USAGE
test/map_test.rb

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs