Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. class A(var t: Int){
  2. def apply() = t
  3. def update(printValue: Boolean, newValue: Int):Unit = {
  4. if (printValue) {
  5. println(newValue)
  6. }
  7. t = newValue
  8. }
  9. }
  10.  
  11. val a = new A(1)
  12. a() эквивалентно a.apply()
  13. a(true) = 2 эквивалентно a.update(true, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement