ruby / TryRuby

This 4th iteration of TryRuby is a website where you can learn the Ruby language.
https://try.ruby-lang.org
MIT License
226 stars 97 forks source link

Me hungry: answer expects a period #41

Closed duianto closed 5 years ago

duianto commented 5 years ago

Page: https://ruby.github.io/TryRuby/ Exercise: Me hungry

The task is:

Now see if you can change the method hungry? to display “Me not hungry” and returning false when the time is less than 12.

The string “Me not hungry” does not end with a . (period) but the answer expects a period:

answer: ^Me not hungry.$

source: https://github.com/ruby/TryRuby/blame/master/translations/en/try_ruby_440.md#L4

The simplest fix is to add a period to the end of the string "Me not hungry" like this:

Now see if you can change the method hungry? to display “Me not hungry.” and returning false when the time is less than 12.

But it would probably be better if the period was removed from both the answer like this:

answer: ^Me not hungry$

and from the "Me hungry." string like this:

      puts "Me hungry"

source: https://github.com/ruby/TryRuby/blame/master/translations/en/try_ruby_440.md#L18

Because I typed the "Me not hungry" string manually and I might not have noticed the period even if it was there.

When I didn't know why my solution wasn't accepted, I even tried flipping the if statement by using >= (even though the previous lessons hadn't thought us about it), and it also works if the period is added to "Me not hungry".

I only noticed the missing period when I decided to look at what the answer was expecting.

easydatawarehousing commented 5 years ago

I agree, removing all trailing fullstops is the best solution. Changed this and also made the regex test a bit less strict. Thanks for your keen observations.