Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/scala/stdlib/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ object Objects extends AnyFlatSpec with Matchers with org.scalaexercises.definit
*/
def privateValuesObjects(res0: String, res1: String) = {
class Person(
val name: String,
private val superheroName: String
private val name: String,
val superheroName: String
) //The superhero name is private!

object Person {
def showMeInnerSecret(x: Person) = x.superheroName
def showMeInnerSecret(x: Person) = x.name
}

val clark = new Person("Clark Kent", "Superman")
val peter = new Person("Peter Parker", "Spider-Man")
val supes = new Person("Clark Kent", "Superman")
val spidey = new Person("Peter Parker", "Spider-Man")

Person.showMeInnerSecret(clark) should be(res0)
Person.showMeInnerSecret(peter) should be(res1)
Person.showMeInnerSecret(supes) should be(res0)
Person.showMeInnerSecret(spidey) should be(res1)
}

}