From: pjb@... (Pascal J. Bourguignon) Date: 2008-06-16T20:59:21+09:00 Subject: Re: how to stop gsub from returning nil Tom Cloyd writes: > Robert Dober wrote: >> Why not write a simple wrapper? >> >> Ruby 1.9 >> class String >> def mysub! *args, &blk >> tap{ gsub!( *args, &blk ) } >> end >> end >> >> Ruby 1.8 or 1.9 too ;) >> ... >> def mysub!... >> gsub!.... >> self >> end >> >> >> Cheers >> Robert >> > Simple answer: I don't know the idiom. I have no idea what you just > said. None. Wrappers in my world are for candy. (!) I haven't caught up > yet with your *last* code, but I'm working on it. Then I'll go to work > on THIS. I much appreciate the learning challenges you're sending my > way. Hope some others are benefiting as well. It's the same as with candy. If you don't like the color of your candy, you take a paper of some other color, and wrap it over the candy. If you still don't like the pattern of this layer, you add another wrapper with a better pattern, and so on. So instead of touching/looking at the candy, you just touch and look the wrapper. Instead of using gsub, which you don't like, use your wrapper method. -- __Pascal Bourguignon__