Created
February 7, 2015 09:48
-
-
Save kevin-lee/ea9b2c155f75b2e7ed5f to your computer and use it in GitHub Desktop.
for IntelliJ IDEA Scala plugin bug https://youtrack.jetbrains.com/issue/SCL-8267
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
import scala.language.implicitConversions | |
case class SomethingElse(value: String) | |
implicit class ToSomethingElse(val value: String) { | |
def toSomethingElse = SomethingElse("###" + value) | |
} | |
val list = Option(List(Option("test"), None, Option("Another"))) | |
val maybeList = list.map { | |
for { | |
maybeValue <- _ | |
mayBeSomethingElse = maybeValue.map(_.toSomethingElse) | |
if (mayBeSomethingElse.isDefined) | |
} yield mayBeSomethingElse.get | |
} | |
println(maybeList) |
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
import scala.language.implicitConversions | |
object Test extends App { | |
case class SomethingElse(value: String) | |
implicit class ToSomethingElse(val value: String) { | |
def toSomethingElse = SomethingElse("###" + value) | |
} | |
val list = Option(List(Option("test"), None, Option("Another"))) | |
val maybeList = list.map { | |
for { | |
maybeValue <- _ | |
mayBeSomethingElse = maybeValue.map(_.toSomethingElse) | |
if (mayBeSomethingElse.isDefined) | |
} yield mayBeSomethingElse.get | |
} | |
println(maybeList) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment