Ruby no implicit conversion of Fixnum into String (TypeError)

前端 未结 2 2038
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-12 12:52

I am trying to answer the following question from Chris Pine\'s \"Learn to Program\" book:

Leap years. Write a program that asks for a starting year and a

2条回答
  •  心在旅途
    2021-02-12 13:17

    Add a .to_i to your gets.chomp calls. You're trying to do math operations on text. When inputted from the console, everything starts out as text, even if it's numeric looking text.

提交回复
热议问题