469,343 Members | 5,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Method syntax producing error

heiro1
29
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 :

Expand|Select|Wrap|Line Numbers
  1. def greeter (name)
  2.  
  3. name = gets.chomp
  4. return "Hi there #{name} sucka!"
  5. end
  6.  
  7. def by_three(number)
  8.  
  9. number = gets.chomp
  10. if number % 3 == 0
  11. return true
  12. else return false
  13. end
May 4 '13 #1
2 5527
heiro1
29
nvm figured it out. Thx anyway!!
May 4 '13 #2
Rabbit
12,516 Expert Mod 8TB
Can you post your solution in case someone else runs into the same problem?
May 4 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Karunakararao | last post: by
3 posts views Thread by Jeff Johnson | last post: by
3 posts views Thread by Joel Finkel | last post: by
1 post views Thread by Alex Dransfield | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.