【发布时间】:2013-12-03 22:15:31
【问题描述】:
试图制作将函数a: => T转换为Validation[Throwable, String]的隐式方法
//works correctly
val t3 = test3
t3.fold(e => println("got error: " + e), s => println("got success: " + s.toString))
def test3: Validation[Throwable, String] ={
Validation.fromTryCatch{
throw new RuntimeException()
"success"
}
}
//does not work, exception is being thrown
val t4 = test4
implicit def trycatch2v[T](a: => T): Validation[Throwable, T] = Validation.fromTryCatch(a)
def test4: Validation[Throwable, String] ={
throw new RuntimeException()
"success"
}
为什么我的implicit def 没有被调用?
【问题讨论】: