mercredi 6 octobre 2021

How to use the ruby time function in a method (if statement)?

Hi I'm doing this question and it is not passing the automated tests and would love to know where i'm going wrong? Many thanks.

question: The hello function Should return (not puts) 'Good morning!' between 09:00 and 12:00 and 'Good afternoon!' between 12:00 and 16:00 and 'Hello!' at all other times

def hello
    t = Time 
    if t = (0900..1200)
        return 'Good morning!'
    elsif t = (1201..1600)
        return 'Good afternoon!'
    else
        return "Hello!"
    end
    
end
hello 

Aucun commentaire:

Enregistrer un commentaire