【发布时间】:2015-04-17 23:30:47
【问题描述】:
在 Scala 中,假设我有一个这样的函数:
def foo[R](x: String, y: () => R): R
所以我可以这样做:
val some: Int = foo("bar", { () => 13 })
有没有办法改变它以使用函数柯里化而不“丢失”第二个参数的类型?
def foo[R](x: String)(y: () => R): R
val bar = foo("bar") <-- this is now of type (() => Nothing)
val some: Int = bar(() => 13) <-- doesn't work
【问题讨论】:
标签: scala