Skip to content

Commit bc7c6b9

Browse files
authored
Merge pull request #264 from abo64/issue-242-acronym-as-object
acronym: Change class to object (issue #242)
2 parents 4b39829 + b6179b5 commit bc7c6b9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

exercises/acronym/example.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
case class Acronym(phrase: String) {
2-
def abbreviate: String = {
1+
object Acronym {
2+
def abbreviate(phrase: String): String = {
33
"[A-Z]+[a-z]*|[a-z]+".r.findAllIn(phrase).map(s => s.head.toUpper).mkString
44
}
55
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
case class Acronym(phrase: String) {
2-
def abbreviate: String = ???
1+
object Acronym {
2+
def abbreviate(phrase: String): String = ???
33
}

exercises/acronym/src/test/scala/AcronymTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class AcronymTest extends FlatSpec with Matchers {
1010
("Complementary metal-oxide semiconductor", "CMOS"))
1111

1212
it should "create acronyms" in {
13-
acronyms.foreach{case (phrase, acronym) => Acronym(phrase).abbreviate should equal(acronym)}
13+
acronyms.foreach{case (phrase, acronym) => Acronym.abbreviate(phrase) should equal(acronym)}
1414
}
1515
}

0 commit comments

Comments
 (0)