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.27 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.26 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.25 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.24 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.23 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.22 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.21 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.20 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.19 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.18 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.17 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.16 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.15 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.14 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.13 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.12 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.11 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.10 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.9 tracks/scala/exercises/bob/example.scala
trackler-2.1.0.8 tracks/scala/exercises/bob/example.scala