Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.