Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. object X
  2. object Y extends X
  3.  
  4. trait T{
  5. // some behavior goes here
  6. }
  7.  
  8. object X extends T
  9.  
  10. object Y extends T {
  11. // additional stuff here
  12. }
  13.  
  14. object X{
  15. def x = 5
  16. }
  17.  
  18. object Y{
  19. import X._
  20. val y = x
  21. }
  22.  
  23. object X {
  24. }
  25.  
  26. object Y {
  27. def a = 5
  28. }
  29.  
  30. implicit def xToY(x: X.type) = Y
  31.  
  32. println(X.a)
  33.  
  34. class Parent {}
  35.  
  36. object Parent extends Parent {}
  37.  
  38. object Child extends Parent {}
  39.  
  40. object X { def f = 5 }
  41.  
  42. object Y {
  43. export X._
  44. def g = 42
  45. def h = f * g
  46. }
  47.  
  48. Y.f // 5
  49. Y.g // 42
  50. Y.h // 210
  51.  
  52. object X { def f = 5; def g = 6 }
  53. object Y { export X.f }
  54. Y.f // 5
  55. Y.g
  56. ^^^
  57. value g is not a member of Y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement