Module: Kernel

Defined in:
lib/active_support/core_ext/kernel.rb

Instance Method Summary collapse

Instance Method Details

#returning(value) ⇒ Object

A Ruby-ized realization of the K combinator, courtesy of Mikael Brockman.

def foo
  returning values = [] do
    values << 'bar'
    values << 'baz'
  end
end

foo # => ['bar', 'baz']


13
14
15
16
# File 'lib/active_support/core_ext/kernel.rb', line 13

def returning(value)
  yield
  value
end