Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3009

Re: Get the real object in a Hash key

From jake kaiden <jakekaiden@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: Get the real object in a Hash key
Date 2011-04-16 10:28 -0500
Organization Service de news de lacave.net
Message-ID <c4a04e41ea966ef483f531fca167b963@ruby-forum.com> (permalink)
References <BANLkTin0FvFkx+kfvXuMxp3_7XkhqkiA_w@mail.gmail.com>

Show all headers | View raw


hi Iñaki,

  i may well not understand exactly what you need to do, and so be 
oversimplifying, but could you do something similar to what Robert 
suggested (but a bit simpler,) and just use an array as each key's 
value?  the header's original name could be added as the first element 
of the array - something like this:

request = Hash.new{|key, value| key[value] = []}

request["FROM"] = ["fRoM", "sip:alice@xample.org"]

p hash["FROM"][0]

#=> "fRoM"


 - j

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Get the real object in a Hash key Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-15 07:50 -0500
  Re: Get the real object in a Hash key Robert Klemme <shortcutter@googlemail.com> - 2011-04-15 08:00 -0500
    Re: Get the real object in a Hash key Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-15 08:14 -0500
      Re: Get the real object in a Hash key Robert Klemme <shortcutter@googlemail.com> - 2011-04-15 08:48 -0500
        Re: Get the real object in a Hash key Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-15 09:46 -0500
        Re: Get the real object in a Hash key Kevin Mahler <kevin.mahler@yahoo.com> - 2011-04-15 09:47 -0500
          Re: Get the real object in a Hash key Robert Klemme <shortcutter@googlemail.com> - 2011-04-15 11:08 -0500
            Re: Get the real object in a Hash key Kevin Mahler <kevin.mahler@yahoo.com> - 2011-04-15 12:39 -0500
              Re: Get the real object in a Hash key Robert Klemme <shortcutter@googlemail.com> - 2011-04-16 15:20 +0200
              Re: Get the real object in a Hash key Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-16 09:51 -0500
                Re: Get the real object in a Hash key Robert Klemme <shortcutter@googlemail.com> - 2011-04-16 18:15 +0200
                Re: Get the real object in a Hash key Iñaki Baz Castillo <ibc@aliax.net> - 2011-04-16 11:55 -0500
                Re: Get the real object in a Hash key Josh Cheek <josh.cheek@gmail.com> - 2011-04-16 11:17 -0500
  Re: Get the real object in a Hash key jake kaiden <jakekaiden@yahoo.com> - 2011-04-16 10:28 -0500

csiph-web