mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
41 lines
541 B
Ruby
41 lines
541 B
Ruby
module YieldSpecs
|
|
class Yielder
|
|
def z
|
|
yield
|
|
end
|
|
|
|
def ze(&block)
|
|
block = proc { block }
|
|
yield
|
|
end
|
|
|
|
def s(a)
|
|
yield(a)
|
|
end
|
|
|
|
def m(a, b, c)
|
|
yield(a, b, c)
|
|
end
|
|
|
|
def r(a)
|
|
yield(*a)
|
|
end
|
|
|
|
def k(a)
|
|
yield(*a, b: true)
|
|
end
|
|
|
|
def rs(a, b, c)
|
|
yield(a, b, *c)
|
|
end
|
|
|
|
def self.define_deep(&inned_block)
|
|
define_method 'deep' do |v|
|
|
# should yield to inner_block
|
|
yield v
|
|
end
|
|
end
|
|
|
|
define_deep { |v| v * 2}
|
|
end
|
|
end
|