Methods, Blocks, & Sorting:Practice Makes Perfect?


#1



https://www.codecademy.com/courses/ruby-beginner-en-ET4bU/1/4?curriculum_id=5059f8619189a5000201fbcb#


no matter what i do it says "uninitialized constant Context::Carlos"
so what am i missing?what detail am i overlooking?


def greeter (name)
    return name
end
puts greeter(Carlos)

def by_three? (number)
    if number % 3 ==0
        return true
    else
        return false
    end
end
puts by_three?(12)


#2

Problem is in this line:

puts greeter(Carlos)

When you write Carlos you are referring to the constant (name begins with a capital letter).

And you should already know about that. This code:

x = 2 + 4
puts x

will print out 6, value of object x, not a letter "x".


So, in this context you should use "Carlos", because you want to pass to function a string, plain text.


#3

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