From 106198ce950e82d92e1e00ab7179bd931b2ba9d5 Mon Sep 17 00:00:00 2001 From: Johannes Hellrich Date: Thu, 9 Mar 2017 21:32:55 +0100 Subject: [PATCH 1/3] Removed superfluous repetition --- src/main/scala/stdlib/Objects.scala | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/main/scala/stdlib/Objects.scala b/src/main/scala/stdlib/Objects.scala index 0601b056..329b6870 100644 --- a/src/main/scala/stdlib/Objects.scala +++ b/src/main/scala/stdlib/Objects.scala @@ -9,21 +9,16 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition /** An object is a singleton. One object, that's it. This object is a replacement of static in Java, and is called upon much in the same way. */ - def singletonObjects(res0: String, res1: String, res2: String, res3: String) { + def singletonObjects(res0: String, res1: Stringg) { object Greeting { def english = "Hi" def espanol = "Hola" - def deutsch = "Hallo" - - def magyar = "Szia" } Greeting.english should be(res0) Greeting.espanol should be(res1) - Greeting.deutsch should be(res2) - Greeting.magyar should be(res3) } /** Here is a proof that an object is a singleton, and not a static method in a class @@ -33,10 +28,6 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition def english = "Hi" def espanol = "Hola" - - def deutsch = "Hallo" - - def magyar = "Szia" } val x = Greeting @@ -71,7 +62,7 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition /** A companion object can also see private values and variables of the corresponding classes' instantiated objects: */ - def privateValuesObjects(res0: String, res1: String, res2: String, res3: String) { + def privateValuesObjects(res0: String, res1: String) { class Person(val name: String, private val superheroName: String) //The superhero name is private! object Person { @@ -80,13 +71,9 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition val clark = new Person("Clark Kent", "Superman") val peter = new Person("Peter Parker", "Spiderman") - val bruce = new Person("Bruce Wayne", "Batman") - val diana = new Person("Diana Prince", "Wonder Woman") Person.showMeInnerSecret(clark) should be(res0) Person.showMeInnerSecret(peter) should be(res1) - Person.showMeInnerSecret(bruce) should be(res2) - Person.showMeInnerSecret(diana) should be(res3) } } From 78b3b47ebffca64f9d77a141ff266c086a826e33 Mon Sep 17 00:00:00 2001 From: hellrich Date: Thu, 9 Mar 2017 22:28:59 +0100 Subject: [PATCH 2/3] removed superfluous "g" --- src/main/scala/stdlib/Objects.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/stdlib/Objects.scala b/src/main/scala/stdlib/Objects.scala index 329b6870..8b9a7d0a 100644 --- a/src/main/scala/stdlib/Objects.scala +++ b/src/main/scala/stdlib/Objects.scala @@ -9,7 +9,7 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition /** An object is a singleton. One object, that's it. This object is a replacement of static in Java, and is called upon much in the same way. */ - def singletonObjects(res0: String, res1: Stringg) { + def singletonObjects(res0: String, res1: String) { object Greeting { def english = "Hi" From abe668a36c4d76c246f4ecdd580f894747cb286e Mon Sep 17 00:00:00 2001 From: hellrich Date: Thu, 9 Mar 2017 22:45:07 +0100 Subject: [PATCH 3/3] removed superfluous examples --- src/test/scala/stdlib/ObjectsSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/scala/stdlib/ObjectsSpec.scala b/src/test/scala/stdlib/ObjectsSpec.scala index 271fb39f..7cb95621 100644 --- a/src/test/scala/stdlib/ObjectsSpec.scala +++ b/src/test/scala/stdlib/ObjectsSpec.scala @@ -11,7 +11,7 @@ class ObjectsSpec extends Spec with Checkers { check( Test.testSuccess( Objects.singletonObjects _, - "Hi" :: "Hola" :: "Hallo" :: "Szia" :: HNil + "Hi" :: "Hola" :: HNil ) ) } @@ -48,7 +48,7 @@ class ObjectsSpec extends Spec with Checkers { check( Test.testSuccess( Objects.privateValuesObjects _, - "Superman" :: "Spiderman" :: "Batman" :: "Wonder Woman" :: HNil + "Superman" :: "Spiderman" :: HNil ) ) }