Accessing hash values

Hi all, this is my first post to the Ruby Forum. Cheers. And thanks for
helping out a newb.

Quesiton: How do you access multiple values from a hash?

For Example, I have a hash of computer names, and their associated user.

the_system = {
“computer-01”=>“jill”,
“computer-02”=>“jack”,
“computer-03”=>“bob”
}

If I want to access the user of one machine, this works great:

puts the_system[“computer-01”]
=>jill

But how do I return multiple user names? (The below throws an error:
‘wrong number of arguments’.)

puts the_system[“computer-01”, “computer-02”]

Thanks.

Sean S.on wrote:

But how do I return multiple user names? (The below throws an error:
‘wrong number of arguments’.)

puts the_system[“computer-01”, “computer-02”]

the_system.values_at(“computer-01”, “computer-02”)

El Miércoles, 2 de Septiembre de 2009, Sean S.on escribió:

"computer-03"=>"bob"

‘wrong number of arguments’.)

puts the_system[“computer-01”, “computer-02”]

the_system.values_at(“computer-01”,“computer-02”)

=> [“jill”, “jack”]

Note that it returns an Array.

Note: Tested in Ruby1.9 but not in 1.8.

Joel VanderWerf wrote:

Sean S.on wrote:

But how do I return multiple user names? (The below throws an error:
‘wrong number of arguments’.)

puts the_system[“computer-01”, “computer-02”]

the_system.values_at(“computer-01”, “computer-02”)

AWESOME! Thanks for the quick reply Joel.

Iñaki Baz C. wrote:

El Miércoles, 2 de Septiembre de 2009, Sean S.on escribió:

"computer-03"=>"bob"

‘wrong number of arguments’.)

puts the_system[“computer-01”, “computer-02”]

the_system.values_at(“computer-01”,“computer-02”)

=> [“jill”, “jack”]

Note that it returns an Array.

Note: Tested in Ruby1.9 but not in 1.8.

And thanks to you as well Iñaki.