-
Notifications
You must be signed in to change notification settings - Fork 0
ruby lib
irxground edited this page Feb 25, 2013
·
4 revisions
def alphabet
return Enumerator.new(self, __method__) unless block_given?
yield 'a'
yield 'b'
# ...
end
{a: 1, b: 2, c: 3}.fetch(:a) #=> 1
{a: 1, b: 2, c: 3}.fetch(:d) # error
{a: 1, b: 2, c: 3}.values_at(:a, :c, :x) #=> [1, 3, nil]
{a: 1, b: 2, c: 3}.except(:a, :c) #=> {b: 2}
{a: 1, b: 2, c: 3}.except(:b, :x) #=> {a: 1, c: 3}
h = {a: 1, b: 2, c: 3}
h.extract!(:a, :b) # => {a: 1, b: 2}
h # => {c: 3}
{a: 1, b: 2, c: 3}.slice(:a, :c) #=> {a: 1, b: 2}