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'] def foo returning [] do |values| values << 'bar' values << 'baz' end end foo # => ['bar', 'baz']
Source Code
# File active_support/core_ext/object/misc.rb, line 27 def returning(value) yield(value) value end
<code/>and<pre/>for code samples.