rubyの基礎知識で質問です。
コード
ruby
1puts("The number of heads ?") 2heads = gets() 3puts("The number of legs ?") 4legs = () 5heads = Integer(heads) 6legs = Integer(legs) 7cranes = (heads * 4 - legs) / (4 -2) 8puts("#{cranes} cranes and #{heads - cranes} turtles")
エラー文
/.rbenv/versions/2.2.3/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/miwataiga/RubymineProjects/untitled/.idea/aaa.rb The number of heads ? 10 The number of legs ? /RubymineProjects/untitled/.idea/aaa.rb:6:in `Integer': can't convert nil into Integer (TypeError) from /RubymineProjects/untitled/.idea/aaa.rb:6:in `<top (required)>' from -e:1:in `load' from -e:1:in `<main>' Process finished with exit code 1
これって、Integer1がきちんと入力されてないってことなんでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/19 05:11
2016/07/20 13:39