From 2b91dc05efaaf3e066995e1a40049847ec36a4c2 Mon Sep 17 00:00:00 2001 From: Warren Sadler Date: Thu, 13 Aug 2020 00:32:58 -0500 Subject: [PATCH] Don't disclose your secret identity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Really loving Scala exercises! I noticed that our heroes were giving away their secret identity and hiding their hero names. It's customary for super heroes to do the inverse. Thanks for the excellent material 🥳 --- src/main/scala/stdlib/Objects.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/stdlib/Objects.scala b/src/main/scala/stdlib/Objects.scala index 029f2a4c..440599fa 100644 --- a/src/main/scala/stdlib/Objects.scala +++ b/src/main/scala/stdlib/Objects.scala @@ -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) } }