Created
November 26, 2014 11:07
-
-
Save Arneball/c003923f417c74b3329c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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