From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-06-23T00:49:15+09:00 Subject: Re: String#decorate On Sun, 22 Jun 2003 16:35:32 +0000, Martin DeMello wrote: > Simon Strandgaard <0bz63fz3m1qt3001@sneakemail.com> wrote: >> On Sun, 22 Jun 2003 06:46:00 +0000, Martin DeMello wrote: >> >>> When chaining methods, it'd be neat to have something that was passed >>> in the string and returned a 'decorated' version, e.g. >>> >>> pp = ary.join(",").decorate {|s| "[#{s}]"} [snip] > > No, I want to decorate the *string*, as a prettier way of doing > > pp = "[" << ary.join(",") << "]" OK.. My assumption was wrong.. I couldn't see which kind of output you wanted.. I understand now. >> It works a bit like 'collect' or 'map' >> >> how about >> >> title.capitalize.map {|t| "\t -- #{author[t]},\"#{t}\""} > > No, String#each iterates over its characters. If I do #map on a string.. then it looks like this: > irb irb(main):001:0> x = "abcdef" => "abcdef" irb(main):002:0> puts x.map {|y| "<#{y}>"} => nil irb(main):003:0> -- Simon Strandgaard