Created
April 21, 2017 14:58
-
-
Save ottomata/d33787567d28f08edd0f81a196fadba2 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 CoolStuff { | |
| implicit class StringImplicits(s: String) { | |
| def withCool(s2: String): String = s + " COOL " + s2 | |
| } | |
| implicit class SeqStringImplicits(strings: Seq[String]) { | |
| def joinEm(sep: String = " | "): String = { | |
| // error: not found: value withCool | |
| strings.map(withCool).mkString(sep) | |
| // But this will work: | |
| // strings.map(s => StringImplicits(s).withCool).mkString(sep) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment