2017-06-05 35 views
0

林堅持與代碼,每當我嘗試運行它,我得到的錯誤:追查「失蹤參數類型擴展功能」

Error:(37, 66) missing parameter type for expanded function 
The argument types of an anonymous function must be fully known. (SLS 8.5) 
Expected type was: com.bfg.domain.model.RunnerSnap 
    def syncPrices(pair: (RunnerSnap, RunnerChange)): RunnerSnap = { 

但錯誤消息不enogh我知道我的需要改變以獲得這個工作。

def syncPrices(pair: (RunnerSnap, RunnerChange)): RunnerSnap = { 
    case (cache: RunnerSnap, delta: RunnerChange) => 
     val newHc = if (delta.hc.isEmpty) cache.runnerId.handicap else delta.hc 
     val id = RunnerId(delta.id, newHc) 
     val prices = MarketRunnerPrices(
     atl = syncPriceVolume(cache.prices.atl, delta.atl), 
     atb = syncPriceVolume(cache.prices.atb, delta.atb), 
     trd = syncPriceVolume(cache.prices.trd, delta.trd), 
     spb = syncPriceVolume(cache.prices.spb, delta.spb), 
     spl = syncPriceVolume(cache.prices.spl, delta.spl), 

     batb = syncLevelPriceVolume(cache.prices.batb, delta.batb), 
     batl = syncLevelPriceVolume(cache.prices.batl, delta.batl), 
     bdatb = syncLevelPriceVolume(cache.prices.bdatb, delta.bdatb), 
     bdatl = syncLevelPriceVolume(cache.prices.bdatl, delta.bdatl), 

     spn = if (delta.spn.isEmpty) cache.prices.spn else delta.spn, 
     spf = if (delta.hc.isEmpty) cache.prices.spf else delta.spf, 
     ltp = if (delta.hc.isEmpty) cache.prices.ltp else delta.ltp, 
     tv = if (delta.hc.isEmpty) cache.prices.tv else delta.tv 
    ) 
     RunnerSnap(id, prices) 
    } 

My question is: Why am I getting this error and what do I need to change in my code to get it working as expected?

回答

1

你缺少pairmatch

def syncPrices(pair: (RunnerSnap, RunnerChange)): RunnerSnap = pair match { 
    case (cache: RunnerSnap, delta: RunnerChange) => 
    ... 
}