Guest User

Untitled

a guest
May 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. pedro:~$ irb
  2. irb> class A ;end
  3.  
  4. irb> class B ;end
  5.  
  6. irb> class C ;end
  7.  
  8. irb> A = B
  9. (irb):4: warning: already initialized constant A
  10. => B
  11.  
  12. irb> class C
  13. irb> def self.hello
  14. irb> puts "hello"
  15. irb> end
  16. irb> end
  17.  
  18.  
  19. irb> B = C
  20. (irb):11: warning: already initialized constant B
  21. => C
  22.  
  23.  
  24. ## Testing the hello static method
  25.  
  26. irb> A.hello
  27. NoMethodError: undefined method `hello' for B:Class
  28. from (irb):16
  29. from :0
  30.  
  31. irb> B.hello
  32. hello
  33.  
  34. irb> C.hello
  35. hello
  36.  
  37. ## Classes
  38. pedro:~$ irb
  39.  
  40. irb> class A ; end
  41. irb> class B ; end
  42. irb> class C ; end
  43.  
  44. irb> A = B
  45. (irb):4: warning: already initialized constant A
  46. => B
  47.  
  48. irb> B = C
  49. (irb):5: warning: already initialized constant B
  50. => C
  51.  
  52. irb> A == B #=> false
  53. irb> B == C #=> true
  54. irb> A == A # => true
Add Comment
Please, Sign In to add comment