Sha256: 1fcfb7e5155a9d85e7dec3941888ffa204b57d2fbcaba4ff5ccceb34a221b52a
Contents?: true
Size: 959 Bytes
Versions: 1
Compression:
Stored size: 959 Bytes
Contents
# Extracted from Active Support 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clean-bitmask-attribute-2.0.0 | lib/bitmask_attribute/core_ext/returning.rb |