|
|
|
|
|
by pathikrit
4342 days ago
|
|
Quite trivial in idiomatic Scala: case class Goal(count: Int) {
def apply() = Goal(count + 1)
def apply(s: String) = s"g${"o" * count}$s"
}
object Goal {
def g() = Goal(1)
}
Non-idiomatic shorter answer: case class g(p: String = "go") {
def apply() = g(p + "o")
def apply(s: String = "o") = p + s
}
|
|