Associative array/Creation: Difference between revisions
m
→[[Ruby]]: Updated formatting. Added link to nil.
(Languages sorted) |
m (→[[Ruby]]: Updated formatting. Added link to nil.) |
||
Line 121:
==[[Ruby]]==
hash={}
hash[666]='devil'
Line 127:
hash[666] # => 'devil'
hash=Hash.new('unknown key')
hash[666]='devil'
Line 133:
hash[666] # => 'devil'
hash=Hash.new{|h,k|h[k]="unknown key #{k}"}
hash[666]='devil'
|