I've checked lambdas and I think it's not possible also to pass more than
one proc as parameter to a method also? I used hash instead
p = lambda { |name|
puts "Hello1" + " " + name
}
z = lambda { |name2|
puts "Hello2" + " " + name2
}
class Test
def blockTest(name,procHash)
procHash['test1'].call(name)
procHash['test2'].call(name)
end
end
test = Test.new
procs = { 'test1' => p, 'test2' => z }
test.blockTest("niyo",procs)
niyo
----- Original Message -----
From: "David A. Black" <dblack / wobblini.net>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Wednesday, November 30, 2005 4:21 AM
Subject: Re: blocks
> Hi --
>
>
> On Wed, 30 Nov 2005, Niyazi Toytok wrote:
>
>> Hello all,
>> I'm learning ruby recently and one thing makes me think. is it possible
>> to pass more than one block to methods? also is it necessary or is there
>> need for that?
>
> You can pass lambda objects around. For every method call, there's
> only one "the" block, though. It's a syntactic construct, analogous
> to the argument list.
>
>
> David
>
> --
> David A. Black
> dblack / wobblini.net
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.13.9/185 - Release Date: 28.11.2005
>
>