Sha256: 9aaa9366b3bebaeec8ab05e95fbc8292e8717e3999ae090fa89eaf50dfe3a42a
Contents?: true
Size: 691 Bytes
Versions: 20
Compression:
Stored size: 691 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 # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCKernel < Test::Unit::TestCase def test_returning foo = returning( values = [] ) do values << 'bar' values << 'baz' end assert_equal( ['bar', 'baz'], foo ) end end =end
Version data entries
20 entries across 20 versions & 1 rubygems