Ruby Ruby Collections Ruby Hashes Ruby Hash Creation

How would you retrieve a hash and put it into ruby?

If you wanted to use the item hash from the create_a_hash.rb and use it in irb?

4 Answers

Okay, try irb -r /home/treehouse/workspace/create_a_hash.rb

That worked for me in a workspace. My create_a_hash.rb was just in the default folder for a new workspace. If you've put yours inside another folder, then you'd have to add that folder name before the file name.

irb -r create_a_hash.rb

If you had hash = Hash.new in create_a_hash.rb, then you could run IRB with the line above, then you'd have access to hash from within your IRB session.

Thanks for the reply. I get a can not open file error trying it this way.

How are you using irb ? Online? Locally on your computer? In a Treehouse workspace?

In a Treehouse workspace.

After closing the window irb -r ./create_a_hash.rb works. Thanks for the help.