How to get the hash value using hash key in ruby
a = {1=>"Active", -1=>"Inactive", 0=>"Under Review"}
a[1] # 'Active'
a[-1] # 'Inactive'
a[0] # 'Under Review'
How to get the hash key using hash value in ruby
a = {1=>"Active", -1=>"Inactive", 0=>"Under Review"}
a.key('Active') #1
a.key('Inactive') #-1
a.key('Under Review') #0
No comments:
Post a Comment