Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3153 > unrolled thread
| Started by | Siratinee Sukachai <ploy.sukachai@gmail.com> |
|---|---|
| First post | 2011-04-19 04:47 -0500 |
| Last post | 2011-04-19 13:17 -0500 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.ruby
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
| From | Siratinee Sukachai <ploy.sukachai@gmail.com> |
|---|---|
| Date | 2011-04-19 04:47 -0500 |
| Subject | How 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]
| From | Zhi-Qiang Lei <zhiqiang.lei@gmail.com> |
|---|---|
| Date | 2011-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]
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
|---|---|
| Date | 2011-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