Hey guys, totally new to Ruby so bear with me please.
I can't get the functions to call is a little script I'm trying to get
to run, just some basic input output to learn my way around Ruby.
###CODE START###
#!/usr/bin/ruby
def output()
age=27
name="Max"
weight=96
print "Age: #{age}\n"
print "\n"
print "Name: #{name}\n"
print "\n"
print "Weight: #{weight}kg\n"
end
def ageChecker()
print "\n"
print "Enter age: "
ageInput=Integer(gets.chomp)
print "You entered your age as: #{ageInput}\n"
if ageInput == age
print "Correct age selected.\n"
nameChecker
elsif ageInput > age
print "You are younger than that, you are #{age}\n"
ageChecker
else ageInput < age
print "You are older than that, you are #{age}\n"
ageChecker
end
end
def nameChecker()
print "\n"
print "Enter name: "
nameInput=String(gets.chomp)
nameInput.capitalize!
print
print "You set your name as: #{nameInput}\n"
print "\n"
if nameInput == name
print "Correct\n"
else
print "Wrong name\n"
nameChecker
end
end
output
###CODE END###
···
--
Posted via http://www.ruby-forum.com/.