Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. module Mod
  2. def foo(x)
  3. x**2
  4. end
  5. end
  6. module Mod2
  7. def foo(x)
  8. x*2
  9. end
  10. end
  11.  
  12. class A
  13. include Mod
  14. def foo(x)
  15. super(x) + 1
  16. end
  17. end
  18. A.new.foo(5) == 26 # true
  19.  
  20. class A
  21. include Mod2
  22. def foo(x)
  23. super(x) + 1
  24. end
  25. end
  26. A.new.foo(5) == 11 # true
  27.  
  28. class A
  29. include Mod
  30. def foo(x)
  31. super(x) + 1
  32. end
  33. end
  34. A.new.foo(5) == 26 # false. Is 11
  35.  
  36. class A
  37. include Mod
  38. def foo(x)
  39. super(x) + 1
  40. end
  41.  
  42. include Mod2
  43. def foo(x)
  44. super(x) + 1
  45. end
  46.  
  47. include Mod
  48. def foo(x)
  49. super(x) + 1
  50. end
  51. end
  52.  
  53. class A
  54. include Mod
  55. def foo(x)
  56. super(x) + 1
  57. end
  58. end
  59. A.new.foo(5) == 26 # true
  60.  
  61. class A
  62. include Mod2
  63. end
  64. A.new.foo(5) == 11 # true
  65.  
  66. class A
  67. include Mod
  68. end
  69. A.new.foo(5) == 11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement