root/trunk/activesupport/lib/active_support/core_ext/kernel.rb
| Revision 949, 317 bytes (checked in by david, 5 years ago) |
|---|
| Line | |
|---|---|
| 1 | module Kernel |
| 2 | # A Ruby-ized realization of the K combinator, courtesy of Mikael Brockman. |
| 3 | # |
| 4 | # def foo |
| 5 | # returning values = [] do |
| 6 | # values << 'bar' |
| 7 | # values << 'baz' |
| 8 | # end |
| 9 | # end |
| 10 | # |
| 11 | # foo # => ['bar', 'baz'] |
| 12 | # |
| 13 | def returning(value) #:nodoc: |
| 14 | yield |
| 15 | value |
| 16 | end |
| 17 | end |
Note: See TracBrowser for help on using the browser.