class Person(val name: String, private val superheroName: String) //The superhero name is private!
object Person {
def showMeInnerSecret(x: Person) = x.superheroName
}
val clark = new Person("Clark Kent", "Superman")
val peter = new Person("Peter Parker", "Spider-Man")
Person.showMeInnerSecret(clark)
Person.showMeInnerSecret(peter)
Login in to like
Login in to comment