7
7stud --
Thanks for all the responses. This may be true:
--
The actual method "send" can take a block, and it passes it to the
method being invoked. If it didn't, it would be impossible to pass a
block to a method when invoking it using send.
--
...but why should a beginner have to figure that out? You shouldn't
have to be a meta-programming guru to figure out the docs. Wouldn't it
be better if beginners posted: "I really think the docs are great."
rather than "beginner: the docs are confusing; expert-response: they are
clear if you are smart."
Why doesn't this work:
def my_meth(*args)
yield
p args
end
my_proc = Proc.new {puts 'hello'}
my_meth(1, 2, 3, &my_proc ) #=>'hello' [1, 2, 3]
obj = Object.new
m = obj.method(my_meth)
m.call([10, 20, 30], &my_proc) #LocalJumpError at yield line
--
The actual method "send" can take a block, and it passes it to the
method being invoked. If it didn't, it would be impossible to pass a
block to a method when invoking it using send.
--
...but why should a beginner have to figure that out? You shouldn't
have to be a meta-programming guru to figure out the docs. Wouldn't it
be better if beginners posted: "I really think the docs are great."
rather than "beginner: the docs are confusing; expert-response: they are
clear if you are smart."
Why doesn't this work:
def my_meth(*args)
yield
p args
end
my_proc = Proc.new {puts 'hello'}
my_meth(1, 2, 3, &my_proc ) #=>'hello' [1, 2, 3]
obj = Object.new
m = obj.method(my_meth)
m.call([10, 20, 30], &my_proc) #LocalJumpError at yield line