scala> def judge(func:()=> Boolean) {
| val result = func()
| println(result)
| }
judge: (func:() => Boolean)Unit
scala> def compare = { 6 > 4 }
compare: Boolean
scala> judge(compare)
<console>:10: error: type mismatch;
found : Boolean
required:() => Boolean
judge(compare)
^
scala> def compare() = { 6 > 4 }
compare:()Boolean
scala> judge(compare)
true
def compare() = { 6 > 4 }
은 무엇을 의미합니까? 두 '비교'기능의 차이점은 무엇입니까? 혼란 스러웠습니다.스칼라에서이 정의는 무엇을 의미합니까?
감사합니다.
스칼라에서 프로그래밍과 사용자의 대답을 읽었으며 이해합니다. 고맙습니다. – user3190192