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


Groups > comp.lang.ruby > #3153 > unrolled thread

How can I do the dictionary?

Started bySiratinee Sukachai <ploy.sukachai@gmail.com>
First post2011-04-19 04:47 -0500
Last post2011-04-19 13:17 -0500
Articles 3 — 3 participants

Back to article view | Back to comp.lang.ruby


Contents

  How can I do the dictionary? Siratinee Sukachai <ploy.sukachai@gmail.com> - 2011-04-19 04:47 -0500
    Re: How can I do the dictionary? Zhi-Qiang Lei <zhiqiang.lei@gmail.com> - 2011-04-19 05:03 -0500
    Re: How can I do the dictionary? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-19 13:17 -0500

#3153 — How can I do the dictionary?

FromSiratinee Sukachai <ploy.sukachai@gmail.com>
Date2011-04-19 04:47 -0500
SubjectHow can I do the dictionary?
Message-ID<4a04255fbe927618065a027462d7d301@ruby-forum.com>
I am a newbie but I'm familial with C#.
I can't find any dictionary class in Ruby.
I need to do like Dictionary<key, List<string>>

Can I do that in Ruby? If yes, how?
Big thanks!

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

[toc] | [next] | [standalone]


#3156

FromZhi-Qiang Lei <zhiqiang.lei@gmail.com>
Date2011-04-19 05:03 -0500
Message-ID<E8FA0072-2BCE-4977-8F6D-26D6956A4BFF@gmail.com>
In reply to#3153
[Note:  parts of this message were removed to make it a legal post.]

I think what you seek is Hash.


On Apr 19, 2011, at 5:47 PM, Siratinee Sukachai wrote:

> I am a newbie but I'm familial with C#.
> I can't find any dictionary class in Ruby.
> I need to do like Dictionary<key, List<string>>
> 
> Can I do that in Ruby? If yes, how?
> Big thanks!
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 


Best regards,
Zhi-Qiang Lei
zhiqiang.lei@gmail.com

[toc] | [prev] | [next] | [standalone]


#3183

From7stud -- <bbxx789_05ss@yahoo.com>
Date2011-04-19 13:17 -0500
Message-ID<a43825cacc4402cde3ea51ee67221091@ruby-forum.com>
In reply to#3153
Siratinee Sukachai wrote in post #993714:
> I am a newbie but I'm familial with C#.
> I can't find any dictionary class in Ruby.
> I need to do like Dictionary<key, List<string>>
>
> Can I do that in Ruby? If yes, how?
> Big thanks!

my_hash = {
  'fruits'  => ['apple', 'pear'],
  'cars'    => ['VW', 'BMW', 'Ford']
}

p my_hash['cars']

--output:--
["VW", "BMW", "Ford"]


my_hash['rocks'] = ['granite', 'quartzite']
p my_hash

--output:--
{"fruits"=>["apple", "pear"], "cars"=>["VW", "BMW", "Ford"], 
"rocks"=>["granite", "quartzite"]}

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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web