Skip to content

Instantly share code, notes, and snippets.

@vvviiimmm
Created February 11, 2017 20:37
Show Gist options
  • Save vvviiimmm/413ef396765999b0a5b0b53f5cd1eac4 to your computer and use it in GitHub Desktop.
Save vvviiimmm/413ef396765999b0a5b0b53f5cd1eac4 to your computer and use it in GitHub Desktop.
case class StringOps(str: String) {
def yell = str.toUpperCase() + "!"
def isQuestion = str.endsWith("?")
}
implicit def stringToStringOps(str: String): StringOps = StringOps(str)
"Hello world".yell // evaluates to "HELLO WORLD!"
"How are you?".isQuestion // evaluates to 'true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment