Bug in Ruby Course - Methods, Blocks & Sorting: Practice Makes Perfect


#1

First part of this exercise asks you to define a greeter method that takes a single string parameter, name, and returns a string greeting that person. It says "Make sure to use return and don't use print or puts".

Yet, no matter how many different ways you try (example code below) you will keep getting the message
"Oops, try again. It looks like your greeter method prints to the console instead of using return.".

def greeter(name)
    greeting = name + ", how are you?"
    return greeting 
end

Note that the error is not from your code but from the lesson. Your code will execute fine. In order to get past this message and go to the next lesson, you will have to do exactly what the lesson is asking you not to do i.e. put a print/puts in the definition of the method.

I was able to go ahead after I coded this!

def greeter(name)
    puts name + ", how are you?"
end

This post is only for information in case someone else is stuck like I was.


#2

Look everything was fine


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.