0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

`*': false can't be coerced into Integer (TypeError)

Posted at

aとbの積が偶数か奇数か

はまった書き方

a,b = gets.chomp.split(" ").map(&:to_i)
if a*b.odd? 
  puts "Odd"
else
  puts "Even"
end

エラー文

`*': false can't be coerced into Integer (TypeError)

原因

a*b.odd?の判定において数字のaとb.odd?のboolean値を掛け算しようとしていたため。
(a*b)と書くのが正解。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?