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.1.0.7 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.6 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.5 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.4 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.3 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.2 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.1 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.0 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.55 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.54 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.53 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.52 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.51 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.50 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.49 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.48 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.47 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.46 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.45 tracks/scala/exercises/bob/example.scala
trackler-2.0.8.44 tracks/scala/exercises/bob/example.scala