From: Derek Lewis Date: 2003-12-12T08:01:34+09:00 Subject: Re: Appending to an array The "p" method is awefully handy: a = [] b = [] c = [1,2,3] a << c b += c p a # => [[1, 2, 3]] p b # => [1, 2, 3] "puts a" and "puts b" both display the same thing: 1 2 3 Not very helpful :) On Fri, 12 Dec 2003, Thomas Adam wrote: > --- Jamis Buck wrote: > > > Thomas Adam wrote: > > > > >vthread << File.new(pathname, > > >"r").readlines().to_s().grep(/^foobar/).uniq() > > > > > > > > > > The << operator for array only appends the single object given to the > > end of the array--it does not concatenate one array onto another. What > > you probably want is the += operator: > > > > vthread += File.new(...).grep(/^foobar/).uniq() > > > > (Assuming, of course, that vthread is an array.) > > James, > > Many thanks for that!! True genius. Solved it completely. I wonder why I > never thought of it myself :) > > kudos_Points++; > > :) > > -- Thomas Adam > > ===== > "The Linux Weekend Mechanic" -- http://linuxgazette.net > "TAG Editor" -- http://linuxgazette.net > > ________________________________________________________________________ > BT Yahoo! Broadband - Save �80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk > Derek Lewis =================================================================== Java Web-Application Developer Email : email@lewisd.com Cellular : 604.312.2846 Website : http://www.lewisd.com "If you've got a 5000-line JSP page that has "all in one" support for three input forms and four follow-up screens, all controlled by "if" statements in scriptlets, well ... please don't show it to me :-). Its almost dinner time, and I don't want to lose my appetite :-)." - Craig R. McClanahan