From: Tom Sawyer Date: 2002-07-12T04:30:11+09:00 Subject: Re: spliter of for...each: looping > "junk#{x}morejunk" is much faster then "junk" << x << "morejunk" oh, FYI, both of these are faster then "junk" + x + "morejunk" ~transami On Thu, 2002-07-11 at 13:22, Tom Sawyer wrote: > > Seems a little cleaner/clearer, but that's IMHO of course :) Your > > method is probably more efficient, since the one I mentioned creates > > an intermediate array. I guess it depends on how performance critical > > the code in question is. > > actually joins faster. just tested it out. also discovered that: > > > thanks for all the help guys! i think i can speed up miter a bit just by > using join. > > ~transmi > > > On Thu, 2002-07-11 at 09:50, Josh Huber wrote: > > Tom Sawyer writes: > > > > > what i now do: > > > q = '' > > > arr.each_with_nindex do |x, n| > > > q << 'junk' << x << 'morejunk' > > > q << ',' if n != -1 > > > end > > > > > > how do you do it with join? > > > > > > note: how i used to do it is probably a tad faster actually > > > > Hmm, how about something like... > > > > arr.collect { |x| 'junk' + x + 'morejunk' }.join(",") > > > > ? > > > > Seems a little cleaner/clearer, but that's IMHO of course :) Your > > method is probably more efficient, since the one I mentioned creates > > an intermediate array. I guess it depends on how performance critical > > the code in question is. > > > > -- > > Josh Huber > > > -- > ~transami > > "They that can give up essential liberty to obtain a little > temporary safety deserve neither liberty nor safety." > -- Benjamin Franklin > > -- ~transami "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin