Created
August 3, 2013 04:29
-
-
Save lu911/6145188 to your computer and use it in GitHub Desktop.
Private Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main { | |
def main(args: Array[String]): Unit = { | |
val test = new Test; | |
test.increment() | |
test.isLess(new Test()); | |
test.print(); | |
} | |
class Test | |
{ | |
private var value = 0 | |
def increment() | |
{ | |
value += 1 | |
} | |
def isLess(other: Test) = | |
{ | |
println(value < other.value) | |
} | |
def print() | |
{ | |
println(value) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment