Re:Object#returning (Ruby's K Combinator)
by pius on Thursday August 28, 2008 @08:41AM
(#289063)
It's (perhaps) worth noting that Object#returning is part of ActiveSupport, not the Ruby Standard Library.
[ Parent
| on HN ]
Re:Object#returning (Ruby's K Combinator)
by raganwald on Thursday August 28, 2008 @10:46AM
(#289162)
True, and worth noting. Also of interest: Ruby 1.9 includes a different implementation of the K Combinator, Object#tap. It's a method rather than a pseudo-function, so instead of:
returning (Fubar.new) do |f|
...
end
Your write: Fubar.new.tap do |f|
...
end
Shameless plug-whoring: The andand gem includes an enhanced Object#tap: http://andand.rubyforge.org