Advertisement
Guest User

nie wiem o co chodzi

a guest
Dec 13th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.37 KB | None | 0 0
  1. class Time(private[this] var h:Int){
  2.   if(h < 0) h = 0
  3.  
  4.   def hour:Int = h
  5.   def hour_=(h:Int) {
  6.     if(h < 0) this.h = 0
  7.     else
  8.     this.h = h
  9.   }
  10. }
  11.  
  12. object Time{
  13.   def apply(h:Int) = new Time(h)
  14. }
  15.  
  16. var t = Time(-61)
  17. t.hour
  18.  
  19. interpreter pokzuje:
  20. defined class Time
  21. defined object Time
  22. t: Time = Time@1579eec9
  23. res61: Int = -61 <- czemu to nie jest 0 !?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement