From: Robert Feldt Date: 2001-11-16T19:19:52+09:00 Subject: [ruby-talk:25403] Re: Arrays, iterators, and map/collect On Fri, 16 Nov 2001, Hal E. Fulton wrote: > Hello all... > Hi, > But what if I want to do an operation > conditionally? Is this still a good way to do it, > in a case where the mapped value is > sometimes/always the same as the original? > > strings.map! { |s| if s[0]==?a then s else "pre." + s end } > I would do it like this but allow myself to shorten it to strings.map! {|s| s[0]==?a ? s : ("pre." + s)} since its a one-liner. Don't you feel it is natural? Why? /Robert