Created
August 9, 2016 12:27
-
-
Save Centaur/883650cfd605b109c90a48fcb59c7ccb to your computer and use it in GitHub Desktop.
代码优化
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 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