def fun(f: (Int) => Unit) = {f(10)f(20)}println("method 1 call:")fun(i => {println("hi"); println(i)})println("method 2 call:")fun{println("hi"); println(_)}輸出:E:\test\scala>scala i.scalamethod 1 call:hi10hi20method 2 call:hi1020為什么第二種調用hi只出現一遍?
2 回答

RISEBY
TA貢獻1856條經驗 獲得超5個贊
int:返回int類型的變量或常量
float:返回float類型的變量或常量
....基本同上....
特殊的:
void:沒有返回值
bool:返回true 或false
- 2 回答
- 0 關注
- 965 瀏覽
添加回答
舉報
0/150
提交
取消