8: Practice Makes Perfect


#1

Even though I'm using return on my code, the program is saying I'm still "printing" instead of using return for my defined greeter argument. Below is the code for all of you to see.

puts "Place the name you want to greet: "
name = gets.chomp

puts "What's the number you want to test?: "
x = gets.chomp.to_i

def greeter(n)
return "Hello! #{n}."
end

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

greet = greeter(name)
puts greet
by_three?(x)

`


#2

Err... I don't quite get why you're doing this from the instruction of that lesson 8:Practice Makes Perfect:

You should be doing something like this:

def greeter(name)
    return name
end
greeter("Aby")

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

Hope it helps! :smile:


#3

Ah. I wanted to do them so I can integrate different lessons learned. Think of it as extra practice. I usually like to build things on top of each other..

Let me try this!


#4

Okay! Awesome. :smile:


#5

thanx, that is very helpfull


#6

You're welcome.

Have fun coding! :smile: