On 8/3/06, nobu@ruby-lang.org <nobu@ruby-lang.org> wrote:
Hi,
At Thu, 3 Aug 2006 22:45:40 +0900,
Tomasz Wegrzanowski wrote in [ruby-talk:205997]:
> Is there some way to define method that takes a block argument
> without calling eval ?
Using 1.9.
--
Nobu Nakada
--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.
p proc_one.call(0,1) # returns 0 according to the web page
p proc_two.call(1) # returns 1,nil according to the web page
p meth_one(0,1) # ???
p meth_two(1) # ???
Would the last two work and return the same result as the direct proc calls?
If so, how would we define a method via define_method that takes a fixed number of parameters?
If not, where does the magic happen that while the proc accepts the arguments,
the method defined by the proc does not?
Proc.new {|x| x}.call(0,1)
(irb):58: warning: multiple values for a block parameter (2 for 1)
from (irb):58
=> [0, 1]
I'm not sure that I like this change.
···
On 8/3/06, Tammo Freese <freese@acm.org> wrote:
Robert Dober wrote:
[...]
> and it seems to make it into Ruby2 since June
> http://pub.cozmixng.org/~the-rwiki/?
> cmd=view;name=Ruby2.0BlockParameterAndMultipleValueAssignment
> which I consider extremly good news
I am suprised that the blocks will work in such a way.
How do these play together with the new define_method ?