On Sun, 06 Jan 2002 10:21:32 +1100, Mark Hahn wrote:


> Imagine that you want to save text back to a file, but only if it
> changed:
> 
> if str.upcase! then File.open('x.txt','w'){|f| f.write str} end

I can certainly see that's a use for it ... but what's the likelihood
someone would really want to attempt to change something to uppercase
and only write it to a file if it changed :-).

Don't worry, I realise you were just giving an example of how the
feature could be used.  I just don't think it's likely to happen
in practice, so it doesn't help me understand why the '!' methods
are designed that way.

I would say that the number of times that happens would be so few,
compared to the surprise factor having it return nil has, that would
not be sufficient justification for Matz to have made that design
decision.

Sounds like Matz could write another book, similar to Bjarne
Stroustrup's "The Evolution of C++" :-).