[ruby-it] Uso di gets

Giovanni Calia mentat59 a gmail.com
Mer 17 Set 2008 16:44:20 CEST


Salve a tutti!!!
La domanda e' la seguente:
Perche' se scrivo
........................
n=6
def fact(n)
  if n==0
    1
  else
    n*fact(n-1)
  end
end
puts fact(n)
.........................
Mi da' il risultato giusto.Mentre se scrivo:
....................................
puts 'Scrivi un numero'
puts ' '
n=gets
def fact(n)
  if n==0
    1
  else
    n*fact(n-1)
  end
end
puts fact(n)
.....................................
Mi da' il seguente errore:
undefined method `-' for #<String:0x3468f4> (NoMethodError)
Dove e' che sbaglio?

Grazie dell'eventuale risposta.
-- 
Posted via http://www.ruby-forum.com/.


More information about the Ml mailing list