You can instantiate it like below:
data = {}
ordata = Hash.new
Then you insert an element toward it like below:
data['lady'] = 'gaga'
data['luna'] = 'maya'
data['aura'] = 'kasih'
To iterate to all of the hash, you need to type:
data.each do |key, value|
puts key +': '+value
end
No comments:
Post a Comment