Sha256: 3d0149cb89dcc935ebd9d32ff6baa60c9b27d9d8ee3e789bd4c6224c42de5cf5

Contents?: true

Size: 572 Bytes

Versions: 7

Compression:

Stored size: 572 Bytes

Contents

module Kernel

  # A Ruby-ized realization of the K combinator.
  #
  #   returning Book.new do |book|
  #     book.title = "Imperium"
  #     book.author = "Ulick Varange"
  #   end
  #
  # Technically, #returning probably should force the return of
  # the stated object irregardless of any return statements that
  # might appear within it's block. This might differentiate
  # #returning from #with, however it also would require
  # implementation in Ruby itself.
  #
  #   CREDIT: Mikael Brockman

  def returning(obj=self) #:yield:
    yield obj
    obj
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/kernel/returning.rb
facets-2.4.1 lib/facets/kernel/returning.rb
facets-2.4.2 lib/core/facets/kernel/returning.rb
facets-2.4.3 lib/core/facets/kernel/returning.rb
facets-2.4.4 lib/core/facets/kernel/returning.rb
facets-2.4.5 lib/core/facets/kernel/returning.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/kernel/returning.rb