1
我定義了下面的類斯卡拉 - Scalaz unMkIdentity NullPointerException異常
private sealed trait Action2[-T1, +R] extends Function1[T1, R] {
def printResults()
}
private abstract class BaseAction[T1, R] extends Action2[T1, R]{
protected var result: R = null
override final def apply(values: T1) : R = {
result = evaluate(values)
result
}
override final def printResults() {
if(result == null)
print("The results have not been evaluated!")
else
printLazyResults(result)
}
protected[this] def printLazyResults(results: R)
protected[this] def evaluate(values: T1) : R
}
我有這個類的實現,每當我嘗試實例給定的實施方法:
implicit def unMkIdentity[A](x: Identity[A]): A = x.value
拋出空指針異常。我首先不明白爲什麼叫(我導入scalaz和Scalaz)以及它爲什麼從屬性結果中得到一個空值...
您能否提供實際拋出異常的代碼?或者將其剝離爲一個最小的例子? – drexin 2012-08-17 10:32:35