Sha256: 0a279e6b7f7d7238654cd6bd43f0be954d449d96dca5cc82b299d26e12a6d886
Contents?: true
Size: 927 Bytes
Versions: 13
Compression:
Stored size: 927 Bytes
Contents
class Object # Returns +value+ after yielding +value+ to the block. This simplifies the # process of constructing an object, performing work on the object, and then # returning the object from a method. It is a Ruby-ized realization of the K # combinator, courtesy of Mikael Brockman. # # ==== Examples # # # Without returning # def foo # values = [] # values << "bar" # values << "baz" # return values # end # # foo # => ['bar', 'baz'] # # # returning with a local variable # def foo # returning values = [] do # values << 'bar' # values << 'baz' # end # end # # foo # => ['bar', 'baz'] # # # returning with a block argument # def foo # returning [] do |values| # values << 'bar' # values << 'baz' # end # end # # foo # => ['bar', 'baz'] def returning(value) yield(value) value end end
Version data entries
13 entries across 13 versions & 3 rubygems