[#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:04249] Re: TABWTDI and Hash.new([])

From: Yasushi Shoji <yashi@...>
Date: 2000-07-28 11:21:53 UTC
List: ruby-talk #4249
From: Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk>
Subject: [ruby-talk:04248] TABWTDI and Hash.new([])
Date: Fri, 28 Jul 2000 11:43:26 +0100 (BST)

[...]

> I can live with this now I know, so I am not really pressing for change,
> but I'd like to know about the serious considerations that make this way
> the better way.  It will help me understand the thinking behind ruby
> better.

I don't know the exact reason why it behave this way but, IMHO, it
might be because in the Ruby World 'thing' is a reference to object,
not the object itself?

Hash.new(thing) is, IMHO,

"create a hash with reference to thing as a default value",

rather than 

"create a hash with thing as a default value"



so, Hash.new([]) can be read,

"create a hash with reference to the anonymous array as a default
value"

rather than

"create a hash with an empty array as a default value"

regards,
--
         yashi

In This Thread