Hi list
I just wrote
o = super( *args)
my_init.bind( o ).call( *args )
o
I write code of this patter way too often, I was just thinking that I
really would like to have
module Kernel
def with_value_return_value a_value, &blk
blk.call a_value
end
end
–
http://ruby-smalltalk.blogspot.com/
All truth passes through three stages. First, it is ridiculed. Second,
it is violently opposed. Third, it is accepted as being self-evident.
Schopenhauer (attr.)
On Nov 26, 2007 1:00 PM, Robert D. [email protected] wrote:
OOps finger just slipping to the nice Enter key
module Kernel
def with_value_return_value a_value, &blk
blk.call a_value
a_value
end
end
Now of course I can write
with_value_return_value( super(*args) ) do |o|
my_init.bind(o).call(*args)
end
Does someone have a name for this? (mine is a joke, a bad one)
Cheers
Robert
http://ruby-smalltalk.blogspot.com/
All truth passes through three stages. First, it is ridiculed. Second,
it is violently opposed. Third, it is accepted as being self-evident.
Schopenhauer (attr.)
with_value_return_value( super(*args) ) do |o|
my_init.bind(o).call(*args)
end
AFAIK this is called #returning in both facets and activesupport. There
has been a discussion about it a while ago.
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/70dadf80a5f57e1f/4433b25ea8402832
On Nov 26, 2007 1:37 PM, Sylvain J.
[email protected] wrote:
with_value_return_value( super(*args) ) do |o|
my_init.bind(o).call(*args)
end
AFAIK this is called #returning in both facets and activesupport. There
has been a discussion about it a while ago.
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/70dadf80a5f57e1f/4433b25ea8402832
Very interesting discussion, and the name seems quite ok with me.
As this was more than a year ago I dare adding some reasoning.
What I like most on this idiom is that the local variable is hiding in
the scope, but much more importantly that you can think on a higher
level
o = something
…
…
…
o
just seems low level and I daresay that the final little o, so
important, will be forgotten quite often
returning( something ) do |o|
…
…
…
end
seems so much more robust.
And for what concerns #tap, well impossible to keep a name like that in
mind :(.
BTW good to know it’s in Facets.
Cheers
Robert
–
Sylvain
–
http://ruby-smalltalk.blogspot.com/
All truth passes through three stages. First, it is ridiculed. Second,
it is violently opposed. Third, it is accepted as being self-evident.
Schopenhauer (attr.)