Sha256: c6e4163c713a583728f8d3d3e7b7d6cb8a6f7bdc241d672a01d13640be05fb45

Contents?: true

Size: 317 Bytes

Versions: 3

Compression:

Stored size: 317 Bytes

Contents

#--
# Courtesy of Mikael Brockman
#++
module Kernel
  # A Ruby-ized realization of the K combinator.
  #
  #   def foo
  #     returning values = [] do
  #       values << 'bar'
  #       values << 'baz'
  #     end
  #   end
  #
  #   foo # => ['bar', 'baz']
  #
  def returning(value)
    yield
    value
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/kernel/returning.rb
facets-0.7.1 lib/facet/kernel/returning.rb
facets-0.7.2 lib/facet/kernel/returning.rb