Sha256: 719321619a0c9da05f051acb0222549bcca2e480b0939bf284dbe79fdf7798cf

Contents?: true

Size: 649 Bytes

Versions: 183

Compression:

Stored size: 649 Bytes

Contents

class Bob {
  def hey(statement: String): String = statement match {
    case Shouting() => "Whoa, chill out!"
    case Question() => "Sure."
    case Silence() => "Fine. Be that way!"
    case _ => "Whatever."
  }

  case object Shouting {
    def unapply(statement: String) =
      hasLetter(statement) && isOnlyUppercase(statement)

    private def hasLetter(s: String) = s.matches(".*[A-Z].*")

    private def isOnlyUppercase(s: String) = s == s.toUpperCase
  }

  case object Question {
    def unapply(statement: String) = statement.endsWith("?")
  }

  case object Silence {
    def unapply(statement: String) = statement.trim.isEmpty
  }
}

Version data entries

183 entries across 183 versions & 1 rubygems

Version Path
trackler-2.0.8.2 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.1 tracks/scala/exercises/bob/example.scala
trackler-2.0.7.0 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.44 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.43 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.42 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.41 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.40 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.39 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.38 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.37 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.36 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.35 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.34 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.33 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.32 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.31 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.30 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.29 tracks/scala/exercises/bob/example.scala
trackler-2.0.6.28 tracks/scala/exercises/bob/example.scala