Help us understand the problem. What is going on with this article?

Rubyでジャバandノットジャバを真にする

More than 1 year has passed since last update.

何しようか

Can (a ==1 && a== 2 && a==3) ever evaluate to true?
JavaScriptで「(a ==1 && a== 2 && a==3)」の結果を真にする手法が議論される | スラド デベロッパー
というのがちょっとした話題らしい。

ならば、ジャバorノットジャバも真にできるのでは!と思って作ってみまし
た。

なぜか手近にあったrubyです。

あなたとジャバ、今すぐ実
     装

jaba.rb
module Jaba
end

module NotJaba
end

class JabaClass
  include Jaba
  include NotJaba
  def ジャバ?
    true
  end
  def ノットジャバ?
    true
  end
  def ==(jaba)
    true
  end
end

and_you = JabaClass.new
ジャバ = Jaba
ノットジャバ = NotJaba

# check ジャバ and ノットジャバ
p and_you.is_a?(ジャバ) && and_you.is_a?(ノットジャバ)
p and_you.ジャバ? && and_you.ノットジャバ?
p and_you == 'ジャバ' && and_you == 'ノットジャバ'

無料jaba.rbのス

$ ruby jaba.rb 
true
true
true
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away