You only call the output function at the bottom of your script.  It does what it does and then you exit.  If you want the other stuff to happen, you have to call it too.


-----Original Message-----
From: ruby-talk [mailto:ruby-talk-bounces / ruby-lang.org] On Behalf Of Richard Curteis
Sent: Monday, November 04, 2013 11:24 AM
To: ruby-talk / ruby-lang.org
Subject: Calling functions

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/.