3
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.

えっ? Ruby で 0 / 0 == 0 + 0 ?

Posted at

さて問題です。Ruby で以下の結果になるようにするには,どうすればいいでしょう。

puts "えっ? Ruby で #{x} / #{x} == #{x} + #{x} ?"
# => えっ? Ruby で 0 / 0 == 0 + 0 ?

puts x / x == x + x
# => true

ただし,x はローカル変数です。
外部ライブラリーは使いません。つまり,x の値は〈組込みクラスもしくは標準添付ライブラリーのクラス〉のインスタンスです。
クラスやモジュールに手は加えません。
メソッドの定義・再定義も行いません。

答えはここをめくってね `require "pathname"; x = Pathname("0")`
3
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
3
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?