【发布时间】:2017-08-01 06:32:24
【问题描述】:
我有以下收藏:
private val commandChain: mutable.Buffer[mutable.Buffer[Long]] = ArrayBuffer()
我需要做以下事情:
def :->(command: Long) = {
commandChain.headOption match {
case Some(node) => node += command
case None => commandChain += ArrayBuffer(command)
}
}
还有比模式匹配更简洁的形式吗?
【问题讨论】:
标签: scala collections option