Skip to content

Instantly share code, notes, and snippets.

@kevin-lee
Created February 7, 2015 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevin-lee/ea9b2c155f75b2e7ed5f to your computer and use it in GitHub Desktop.
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
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)
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