Getting syntax error on Methods, blocks and sorting


#1



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


Syntax error ?


def greeter?(name)
    return "Hey" + name + ", how's going ?"
end
greeter("Mark")

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


#2

@markiscoding,
You are forgetting an end keyword to end the IF ELSE structure..

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

https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Control_Structures


#3

Thank you. I edited my code but now it says "greeter?" isn't defined but it's defined on the very beginning. I don't get it ......

Updated code:

def greeter?(name)
return "Hey" + name + ", how's going ?"
end
greeter?("Mark")

def by_three?(number)
if number % 3 == 0

    return true
else
    return false
end

end
by_three?(30)


#4

It's ok now ... I had to remove the question mark from Greeter.


#5

Although I'm getting "Way to go" I see in preview that my Greeter don't get returned.

Code:

def greeter(name)
return "Hey" + name + ", how's going ?"
end
greeter("Mark")

def by_three?(number)
if number % 3 == 0

    return true
else
    return false
end

end
by_three?(30)

Any ideas ?


#6

@markiscoding,
The return statement will return a =Result= without Display
Now to Display the =Result=
you can do two things:
-1 direct Display

puts   greeter("Mark")

-2 indirect Display

the_result = greeter("Mark")
puts the_result

#7

Wow ... thanks mate !

I tried it but at this point program is not allowing me to use puts or print. Only return. But thanks !

Have a great day ! ! !


#8

@markiscoding
Have a read through
https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls