[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:04024] Re: Array.uniq! returning nil

From: matz@... (Yukihiro Matsumoto)
Date: 2000-07-14 16:26:36 UTC
List: ruby-talk #4024
Hi,

In message "[ruby-talk:04004] Re: Array.uniq! returning nil"
    on 00/07/14, Aleksi Niemel<aleksi.niemela@cinnober.com> writes:

|Still I don't know if the fact that method! can return nil was just
|introduced when needed (as someone pulled in some code to show it in this
|thread), and the current functionality remains because there's loads of code
|relying on it, or whether it was thought, and decided, to be inconsistent
|with the principle I just phrased. (Perhaps because Ruby is following here
|some other clean and simple priciple.)

Actually, it is mainly a historical reason.

In old days, non bang methods returns copy if modified, and original
if not modified.  So you could distinguish whether modify is done by
comparing the return value with the original object.  But bang method
could not provide the way to know if modified or not.  That was why I
made bang methods to return nil if not modified the object.

But later, non bang behavior was changed to return copy always, to
avoid copy/original confusion.  But I still expected the need to check
modification, so changing bang behavior was abandoned.

							matz.

In This Thread

Prev Next