Guest User

Untitled

a guest
Apr 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #! /usr/local/bin/ruby25
  2.  
  3. class Integer
  4. alias :' >' :'>'
  5. alias :' <' :'<'
  6.  
  7. def >(other)
  8. if self.send(:' >', other) then
  9. other
  10. else
  11. nil
  12. end
  13. end
  14.  
  15. def <(other)
  16. if self.send(:' <', other) then
  17. other
  18. else
  19. nil
  20. end
  21. end
  22. end
  23.  
  24. class NilClass
  25. def >(other)
  26. self
  27. end
  28.  
  29. def <(other)
  30. self
  31. end
  32. end
  33.  
  34. p(if 1<2<3 then 'Y' else 'N' end)
  35. p(if 1<2>3 then 'Y' else 'N' end)
  36. p(if 1>2<3 then 'Y' else 'N' end)
  37. p(if 1>2>3 then 'Y' else 'N' end)
  38.  
  39. p(if 3<2<1 then 'Y' else 'N' end)
  40. p(if 3<2>1 then 'Y' else 'N' end)
  41. p(if 3>2<1 then 'Y' else 'N' end)
  42. p(if 3>2>1 then 'Y' else 'N' end)
Add Comment
Please, Sign In to add comment