Method syntax producing error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • heiro1
    New Member
    • Jan 2013
    • 29

    Method syntax producing error

    I am learning Ruby using codecademy and the current exercise tells the user to :

    Define two methods in the editor:

    A greeter method that takes a single string parameter, name, and returns a string greeting that person. (Make sure to use return and don't use print or puts.)

    A by_three? method that takes a single integer parameter, number, and returns true if that number is evenly divisible by three and false if not. Remember, it's a Ruby best practice to end method names that produce boolean values with a question mark.

    Based on that I came up with some code but it doesn't work and I do not know how to fix it or what I am missing. Any push in the right direction is greatly appreciated! Here is my code :

    Code:
    def greeter (name)
    
    name = gets.chomp
    return "Hi there #{name} sucka!"
    end
    
    def by_three(number)
    
    number = gets.chomp
    if number % 3 == 0
    return true
    else return false
    end
  • heiro1
    New Member
    • Jan 2013
    • 29

    #2
    nvm figured it out. Thx anyway!!

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Can you post your solution in case someone else runs into the same problem?

      Comment

      Working...