From: Kent Dahl Date: 2003-04-05T20:43:17+09:00 Subject: Re: Strangeness in Find.find Brian Candler wrote: > > I was just looking at lib/ruby/1.8/find.rb and I am stumped by the marked > line: > > def find(*paths) # :yield: path > paths.collect!{|d| d.dup} # << ?! > while file = paths.shift > ... etc > > For each element of the 'paths' array, it is duplicating that entry, then > collecting those duplicates into a new array, I do not think it makes a new array. It uses the same array object. Notice the "!". > and then immediately throwing > away that array! No. It reuses the array object created upon calling it, which probably saves both space and time. As for why the dup-ing is necessary, I don't know. -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 5. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)