-
-
Save yuroyoro/1094820 to your computer and use it in GitHub Desktop.
#daimon.scala
This file contains 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 extends App { | |
trait Reversible { | |
val s:String | |
def reverseOrder = s reverse | |
def reverseCases = s collect{ | |
case c if c.isUpper => c.toLower | |
case c if c.isLower => c.toUpper | |
case c => c | |
} | |
} | |
implicit def string2Reversible(str:String) = new Reversible{ val s = str } | |
println("AbcDEf123".reverseOrder) | |
println("AbcDEf123".reverseCases) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment