From: "David A. Black" Date: 2005-11-04T20:48:28+09:00 Subject: Re: two arguments in a block? Hi -- On Fri, 4 Nov 2005, Daniel Wislocki wrote: > You're not actually "passing" v2 anywhere. The |v1, v2| creates two > variables, v1 and v2, local to that block. It's the method itself that > supplies the values of v1 and v2. Are you sure what you're trying to > do is correct? It's a little different than that: at the time of |v1,v2| v2 already exists, since it was created before the block. So the overall effect is like: v2 = [] v1, v2 = some_scalar_value which reassigns nil to v2. David > > On 11/4/05, Kev Jackson wrote: >> Hi, >> >> I want to pass an array into a block like so >> >> v2 = [] >> object.some_method_that_takes_a_block do | v1, v2| >> v2.push v1.action >> end >> >> causes a undefined method push for nil >> >> the problem is that v2 gets assigned as nil as it gets passed through, >> is there any way around this? >> >> I don't really want to open the original class and try to add a new >> method signature (I hope that's not how to get it to accept to variables) >> >> Kev >> >> > -- David A. Black dblack@wobblini.net