[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02613] Structs and dictionary keys

From: Wes Nakamura <wknaka@...>
Date: 2000-05-02 09:26:56 UTC
List: ruby-talk #2613
Hi,

What's the purpose of the name when you create a new Struct?

From the docs:

dog = Struct.new("Dog", :name, :age)

Can you reference something via the name "Dog"?



Also, are frozen arrays suitable for dictionary keys?

Will the second [1,2] always dereference properly?

 { [1,2].freeze => "test" }[[1,2]]

I know that if you don't freeze the key and then change it, apparently
you can't access the value via the key at all anymore. 


thanks,
Wes.

In This Thread

Prev Next