From: Dark Ambient Date: 2006-08-13T09:25:59+09:00 Subject: Re: map or collect with multidimension arrays Just wanted to thank everyone for the help. No doubt I'll be back for some other issues :) Stuart On 8/12/06, Morton Goldberg wrote: > You're right. Shouldn't use << in this case. If OP wanted x > modified, then could have just written: > > x = [["john", "doe"], ["mary", "jane"], ["jim","richards"], > ["sue","scott"]] > x.each {|i| i << "name"} > > Regards, Morton > > On Aug 12, 2006, at 2:11 PM, dblack@wobblini.net wrote: > > > Hi -- > > > > On Sun, 13 Aug 2006, Morton Goldberg wrote: > >> > >> On Aug 12, 2006, at 11:08 AM, Dark Ambient wrote: > >> > >>> I know they are interchangeable > >>> But I can't make it work. > >>> For instance - > >>> x = [["john", "doe"],["mary", "jane"],["jim","richards"], > >>> ['sue","scott"]] > >>> y = x.map {|i| i + "name" } > >>> p y > >>> It's returning nil on me ???? > >> > >> Try > >> > >> x = [["john", "doe"],["mary", "jane"],["jim","richards"], > >> ["sue","scott"]] # <= "sue" not 'sue" > >> y = x.map {|i| i << "name" } > >> p y > > > > The disadvantage of that is that it changes the original objects > > inside x. > > > > > > David > > > > -- > > http://www.rubypowerandlight.com => Ruby/Rails training & consultancy > > ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <----- > > http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log > > http://www.manning.com/black => book, Ruby for Rails > > http://www.rubycentral.org => Ruby Central, Inc. > > > > >