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