package base05
/**
* Created by dd on 2016/5/19 0019.
*/
object demo02 extends App{
//Option类型
def commentOnPractice(input: String) ={
if(input == "test") Some("good") else None
}
for(input <- Set("test","hack")){
val comment = commentOnPractice(input)
println("input "+input+" comment "+
comment.getOrElse(" Found no comments"))
}
}
Programming Scala第5章demo02 Option类型
最新推荐文章于 2023-04-05 17:10:06 发布