Clojure's 'let' equivalent in Scala

后端 未结 6 1996
不思量自难忘°
不思量自难忘° 2020-12-29 22:50

Often I face following situation: suppose I have these three functions

def firstFn: Int = ...
def secondFn(b: Int): Long = ...
def thirdFn(x: Int, y: Long, z:         


        
6条回答
  •  攒了一身酷
    2020-12-29 23:43

    Why not use pattern matching here:

    def calculate(a: Long) = firstFn match { case f => secondFn(f) match { case s => thirdFn(f,s,s + a) } }

提交回复
热议问题