16
最小化的例子如下:为什么不允许重载方法内的方法(例如重载闭包)?
object Main extends App {
def f = {
def giveMeBigDecimal(x: String) = BigDecimal(x)
def giveMeBigDecimal(x: Double) = BigDecimal(x)
(giveMeBigDecimal("1.0"), giveMeBigDecimal(1.0))
}
}
斯卡拉2.9.2编译器一直在说我,method giveMeBigDecimal is defined twice
我知道我workaround this,但好奇,为什么这样的限制存在哪有。
可能的重复 - http://stackoverflow.com/questions/7550302/why-method-overloading-does-not-work-inside-another-method – Rogach
@Rogach它主要是问和答案*如何解决*不*为什么* –