Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed superfluous repetition #74

Merged
merged 3 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
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
17 changes: 2 additions & 15 deletions src/main/scala/stdlib/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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: String) {
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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

}
4 changes: 2 additions & 2 deletions src/test/scala/stdlib/ObjectsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ObjectsSpec extends Spec with Checkers {
check(
Test.testSuccess(
Objects.singletonObjects _,
"Hi" :: "Hola" :: "Hallo" :: "Szia" :: HNil
"Hi" :: "Hola" :: HNil
)
)
}
Expand Down Expand Up @@ -48,7 +48,7 @@ class ObjectsSpec extends Spec with Checkers {
check(
Test.testSuccess(
Objects.privateValuesObjects _,
"Superman" :: "Spiderman" :: "Batman" :: "Wonder Woman" :: HNil
"Superman" :: "Spiderman" :: HNil
)
)
}
Expand Down