Skip to content

Instantly share code, notes, and snippets.

@Arneball
Created November 26, 2014 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arneball/c003923f417c74b3329c to your computer and use it in GitHub Desktop.
Save Arneball/c003923f417c74b3329c to your computer and use it in GitHub Desktop.
class Str(val str: String) extends AnyVal {
def isEmpty = str == null || str.isEmpty
def _1 = str.charAt(0)
def _2 = str.substring(1)
}
object Str {
def unapply(str: String): Str = new Str(str)
}
object StrTest {
def remLeadingZeros(str: String): String = str match {
case "" => ""
case Str('0', tail) => remLeadingZeros(tail)
case Str(_, tail) => tail
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment