method

to_proc

Importance_1
v2_6_3 - Show latest stable - 0 notes - Class: Hash
to_proc() public

Returns a Proc which maps keys to values.

h = {a:1, b:2}
hp = h.to_proc
hp.call(:a)          #=> 1
hp.call(:b)          #=> 2
hp.call(:c)          #=> nil
[:a, :b, :c].map(&h) #=> [1, 2, nil]
Show source
Register or log in to add new notes.