Methods, Blocks, & Sorting:Practice Makes Perfect?


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
puts greeter(Carlos)

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


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.


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