【发布时间】:2017-11-30 01:36:25
【问题描述】:
我是一个 python/go 编码器,并且是 scala 的新手。我有一段带有 if 和 else 的工作代码,但是有什么关于以“scala”方式编写它的建议吗?
if (sp.bin_an.size() > 0) {
sp.bin_an.asScala.toList.foreach { an =>
if (an.host != null && an.host.name != "" && an.routine == "xx") {
service = an.host.name
}
}
【问题讨论】:
-
@Ryan:你能帮忙详细说明一下吗?
-
sp.bin_an的类型是什么? -
@jwvh 对象列表(带属性)
标签: python scala functional-programming user-defined-functions scala-collections