From: Daniel Carrera Date: 2003-03-28T18:27:27+09:00 Subject: Re: Array question On Fri, Mar 28, 2003 at 06:14:11PM +0900, Tim Bates wrote: > On Fri, 28 Mar 2003 7:37 pm, Daniel Carrera wrote: > > Uh, no it doesn't strike me as what 'join' is supposed to do. > > Intuitively, I think that a 'join' function should only join the entries > > of the array and not modify the entries themselves. > > I would agree - otherwise you're combining the functionality of 'join' with > 'collect'. What might be useful is for join to take a block which decides > what separator to use based on the value of the previous item, That'd be cool. > eg: > (1..10).to_a.join { |i| > i % 2 == 0 ? " " : "-" > } # => "1-2 3-4 5-6 7-8 9-10" > This is a trivial example, and I can't think of a real example off the top of > my head, # Set the path according to the OS. path = directories.joing { |i| CONFIG["host_os"] =~ /Win/ ? "%" : ":" } -- Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137 -- depone: depone (di-POHN) verb tr., intr. To declare under oath.