LoginSignup
4
0

More than 5 years have passed since last update.

a == 1 && a == 2 && a == 3にするRubyスクリプト

Last updated at Posted at 2018-01-24

Ruby2.5で書きました.

irb(main):001:0> a = [1,2,3]
=> [1, 2, 3]
irb(main):002:0> a.class.class_eval do
irb(main):003:1*   def ==(n)
irb(main):004:2>     self.shift == n
irb(main):005:2>   end
irb(main):006:1> end
=> :==
irb(main):007:0> a == 1 && a == 2 && a == 3
=> true
4
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
4
0