Sha256: a1bb368e61492996ab8ea52a76db72f5ec3b20b2d2f688dca6194aee6c1f59e3

Contents?: true

Size: 570 Bytes

Versions: 14

Compression:

Stored size: 570 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

14 entries across 14 versions & 2 rubygems

Version Path
puppet-module-0.3.4 vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb
puppet-module-0.3.3 vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb
puppet-module-0.3.2 vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb
puppet-module-0.3.0 vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb
facets-2.8.4 lib/core/facets/kernel/returning.rb
facets-2.8.3 lib/core/facets/kernel/returning.rb
facets-2.8.2 lib/core/facets/kernel/returning.rb
facets-2.8.1 lib/core/facets/kernel/returning.rb
facets-2.8.0 lib/core/facets/kernel/returning.rb
facets-2.7.0 lib/core/facets/kernel/returning.rb
facets-2.6.0 lib/core/facets/kernel/returning.rb
facets-2.5.0 lib/core/facets/kernel/returning.rb
facets-2.5.1 lib/core/facets/kernel/returning.rb
facets-2.5.2 lib/core/facets/kernel/returning.rb