Skip to content

Instantly share code, notes, and snippets.

@pocke
Created November 20, 2016 01:50
Show Gist options
  • Save pocke/fc6077fd9710e6c73934ce1af07bb0af to your computer and use it in GitHub Desktop.
Save pocke/fc6077fd9710e6c73934ce1af07bb0af to your computer and use it in GitHub Desktop.
class Fixnum
def <(right)
super ? right : nil
end
def >(right)
super ? right : nil
end
def >=(right)
super ? right : nil
end
def <=(right)
super ? right : nil
end
end
class Bignum
def <(right)
super ? right : nil
end
def >(right)
super ? right : nil
end
def >=(right)
super ? right : nil
end
def <=(right)
super ? right : nil
end
end
class Float
def <(right)
super ? right : nil
end
def >(right)
super ? right : nil
end
def >=(right)
super ? right : nil
end
def <=(right)
super ? right : nil
end
end
class NilClass
def <(right)
right.is_a?(Numeric) ? nil : super
end
def >(right)
right.is_a?(Numeric) ? nil : super
end
def >=(right)
right.is_a?(Numeric) ? nil : super
end
def <=(right)
right.is_a?(Numeric) ? nil : super
end
end
@pocke
Copy link
Author

pocke commented Nov 20, 2016

if 1 < x < 10
  puts '1 < x < 10'
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment