[#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:04235] RE: @ variables not updated within method?

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-07-27 17:45:04 UTC
List: ruby-talk #4235
Hugh says:
> I have a program, too large to post here, and an object in it with a
> variable:

Well, you could try to make a short example which does not work. Usually
this makes it easier to other to help you out and as a side effect many
problems magically vanish :) - at least that happens me all the time.

> Are there any catches I should be looking out for when doing 
> this sort of thing?
> @chunks = Hash.new([])
> It is a hash of arrays.  

This is not a hash of arrays. @chunks refers to a normal array which has a
default value an empty array.

  ruby -e 'h=Hash.new([]); h[1]="bar"; p h["foo"]; p h;'
  []
  {1=>"bar"}

	- Aleksi

In This Thread

Prev Next