Skip to content

Instantly share code, notes, and snippets.

@Centaur
Created August 9, 2016 12:27
Show Gist options
  • Save Centaur/883650cfd605b109c90a48fcb59c7ccb to your computer and use it in GitHub Desktop.
Save Centaur/883650cfd605b109c90a48fcb59c7ccb to your computer and use it in GitHub Desktop.
代码优化
import util._
trait Idiomatic {
def step1(s: String): Try[List[String]]
def step2(s: String): Option[String]
def logic(src: String) = {
for(data1 <- step1(src)) {
data1.find(p => step2(p).isDefined) match {
case Some(s) => println(s"do something with $s")
case None => println("do something else")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment