Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment #3 #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Assignment #3 #11

wants to merge 2 commits into from

Conversation

annavester
Copy link

Panda and Tiger Levels

def find_show
dow = { Monday: 1, Tuesday: 2, Wednesday: 3, Thursday: 4, Friday: 5, Saturday: 6, Sunday: 7 }
puts "Pick a day of week: Use 1 for Monday ... 7 for Sunday"
user_pick = dow.key ( gets.to_i )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of a hash here! I think that's exactly the way to go. Here you are really retrieving the key from a value (Monday being the key, 1 being the value).

Instead, maybe try:

  days_of_week = {1=>"Monday", 2=>"Tuesday"}
  puts "Pick a day of week: Use 1 for Monday ... 7 for Sunday"
  user_pick = days_of_week.fetch( gets.to_i ) { puts "sorry, not found"}

@jwo
Copy link
Member

jwo commented Dec 2, 2012

Great job! I added some comments on using fetch vs keys on the hash.

Did you have any troubles getting postgres installed?

@annavester
Copy link
Author

Thanks. I haven't had any installing pg. It worked just fine. Also, I've update the hash format, but I couldn't figure out how to actually show that not found message. I tried modifying if statement here:

network.shows.each { |show| puts show if show.day_of_week == user_pick }

But it didn't work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants