Site Archives hash
Ruby 1.9.1: Hash
In ruby 1.9.1 has many changes for Hash some useful changes are below:
RUBY_VERSION => 1.8.6
RUBY_VERSION => 1.9.1
>> {’name’, "Akhil"}
=> syntax error, unexpected ‘,’, expecting tASSOC
>> {name: "Akhil"}
=> {:name=>"Akhil"}
Now Hash preserves order:
RUBY_VERSION => 1.8.6
>> hash = {:a=> ‘A’, :b=>’B', :c=>’C', :d=>’D'}
=> {:b=>"B", :c=>"C", :d=>"D", :a=>"A"}
>> hash.to_a
=> [[:b, "B"], [:c, "C"], [:d, "D"], [:a, "A"]]
>> hash.keys
=> [:b, [...]
Find It Quickly
Find what you're looking for quickly by using our keyword search. Can't find it? Try our links below.