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
| // Base64 encode | |
| val text = "This is plaintext." | |
| val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes()) | |
| // Base64 decode | |
| val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded)) | |
| println(textDecoded) |
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 Test { | |
| // Implicit class is also a new feature in scala 2.10 | |
| implicit class CounterSC(val sc: StringContext) extends AnyVal { | |
| // Define functions that we want to use with string interpolation syntax | |
| def partsCount(args: Any*): Int = sc.parts.length | |
| def argsCount(args: Any*): Int = args.length | |
| def tokenCount(args: Any*): Int = sc.parts.length + args.length | |
| def getParts(args: Any*): String = |