Defining a method with conditional statements


Hi I am trying to figure out why this method isn't working. Can someone help me out?

def number(i)
i = gets.chomp
unless i.is_a? Integer
return "You must type in an integer."
if i > 0
puts "This is a positive integer!"
elsif i < 0
puts "This is a negative integer!"
puts "You typed in zero!"



"What excercise are you on?


This is me working a little on my own to test myself on conditional statements. It's not directly off a Codecademy exercise.


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