Created
October 2, 2009 19:38
-
-
Save p3t0r/200036 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
object Main { | |
implicit def extendString(string:String) = new MyString(string) | |
def main(args: Array[String]) :Unit = { | |
val testValue = "1000"; | |
println(testValue.getClass().getName()) // prints java.lang.String | |
println(testValue.isNumeric) // prints true | |
println(testValue.lastIndexOf("0")) // prints 3 | |
println(testValue.getClass().getName()) // prints java.lang.String | |
} | |
class MyString(string:String){ | |
def isNumeric = string.matches("-?\\d+(.\\d+)?") | |
def lastIndexOf(value:String) = 666 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment