Skip to content

Conversation

@ardder
Copy link

@ardder ardder commented Jul 15, 2013

No description provided.

watchman.rb Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably recommend to either stick with puts or STDOUT.

@jwo
Copy link
Member

jwo commented Jul 15, 2013

Great job! Only stylistic points to mention. yay!

I keep thinking about this line:

puts "1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday, 7: Sunday or Q: Quit"

It's not bad --- but it does repeat some information. Like the WEEK_DAY above as a constant. I might do something like:

COMMANDS = {"Q" => "Quit"} 
all_choices = WEEK_DAY.merge(COMMANDS)
puts all_choices.map{ |k,v| "#{k}: #{v}"}.join(" or ")

Then later, you could do something like

day = select_day

if all_choices[day].nil?
  puts "invalid choice #{day}, please try again"
  next
end

Unsure if that really makes it better not, but wanted to show an alternate flow.

@ardder
Copy link
Author

ardder commented Jul 16, 2013

I think you are right. I especially like all_choice[day].nil?. It can replace my ugly regex!

BTW, I also finished the assignment of Episode 2. Can you check my code?

Thanks, @jwo

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