Anonymous user
Associative array/Creation: Difference between revisions
Remove double entry for Ruby
(Added Scala example) |
(Remove double entry for Ruby) |
||
Line 232:
==[[Ruby]]==
[[Category:Ruby]]
hash={}
hash[666]='devil'
Line 238:
hash[666] # => 'devil'
hash=Hash.new('unknown key')
hash[666]='devil'
Line 244:
hash[666] # => 'devil'
hash=Hash.new{|h,k|h[k]="unknown key #{k}"}
hash[666]='devil'
hash[777] # => 'unknown key 777'
hash[666] # => 'devil'
===Iterate over key/value===
Line 355 ⟶ 354:
Create a generic mapping function that applys a callback to elements in a list:
==[[Smalltalk]]==
|