Scala multiple assignment to existing variable

前端 未结 5 692
独厮守ぢ
独厮守ぢ 2021-01-11 17:02

I can do something like

def f(): Tuple2[String, Long] = ...
val (a, b) = f()

What about if the variables are already existing? I\'m runnin

5条回答
  •  天涯浪人
    2021-01-11 17:33

    It works for new values because that syntax is treated as a pattern matching, just like case statements. So, as Alex said, you cannot do it.

提交回复
热议问题