On Sun, Dec 9, 2012 at 1:35 PM, Ferdous ara <[email protected]> wrote:
> but will this work : #value["host_display_name"] ??
> I will try in a bit ..
No. For lookup by value you can use Hash#rassoc:
irb(main):003:0> h={"foo" => "bar"}
=> {"foo"=>"bar"}
irb(main):004:0> h.rassoc "bar"
=> ["foo", "bar"]
irb(main):005:0> key, val = h.rassoc "bar"
=> ["foo", "bar"]
irb(main):006:0> key
=> "foo"
Be warned though that this may be inefficient. You probably want a
second Hash keyed by value.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en