컴파일러가 반환 아무것도, 비어이?스칼라에서 '빈'case 문은 무엇을 의미합니까?
foo match {
case bar: Bar => println("First case statement")
case _ =>
}
두 번째 사건을 해석 않습니다 방법.
val res: Unit = new foo match {
case bar: Bar => println("First case statement")
case _ =>
}
당신이 (Unit
을 반환) 대신 println
의 뭔가 반환 명세서 변경하는 경우 :
val res: Any = new foo match {
case bar: Bar => "it's a bar"
case _ =>
}
지금 컴파일러가 Any
를 추정했습니다이 처음이기 때문에
답변과 수정에 동의합니다. –