Flowdock
method

assoc

Importance_1
v1_9_3_125 - Show latest stable - 0 notes - Class: Hash
assoc(p1) public

Searches through the hash comparing obj with the key using ==. Returns the key-value pair (two elements array) or nil if no match is found. See Array#assoc.

h = {"colors"  => ["red", "blue", "green"],
     "letters" => ["a", "b", "c" ]}
h.assoc("letters")  #=> ["letters", ["a", "b", "c"]]
h.assoc("foo")      #=> nil
Show source
Register or log in to add new notes.