如何解决scala中错误的前向引用错误。该错误究竟是什么意思?
def daysInMonth(year: Int, month: Int): Int = {
val daysInMonth: Int = month match {
case 1 => 31
case 3 => 31
case 5 => 31
case 7 => 31
case 8 => 31
case 10 => 31
case 12 => 31
case 2 => {
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) 29 else 28
}
case _ => 30
}
daysInMonth
}
下面的语句显示了前向引用错误
println(daysInMonth(2011,12))