Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3183
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: How can I do the dictionary? |
| Date | 2011-04-19 13:17 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <a43825cacc4402cde3ea51ee67221091@ruby-forum.com> (permalink) |
| References | <4a04255fbe927618065a027462d7d301@ruby-forum.com> |
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/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar | Unroll thread
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
csiph-web