感觉scala自由度太高了,多人协作的时候看别人代码累的够呛,最后肯定还是得额外约束。其实实际开发成本不亚于Java。
2016-07-30
楼下那个死循环的,应该是这样:
@annotation.tailrec
def factorial(n: Int, m: Int): Int = {
println("n:=" +n)
if (n <= 0) m
else{
println("m:"+m)
factorial(n - 1, m * n)}
}
factorial(5,1)
@annotation.tailrec
def factorial(n: Int, m: Int): Int = {
println("n:=" +n)
if (n <= 0) m
else{
println("m:"+m)
factorial(n - 1, m * n)}
}
factorial(5,1)
2016-07-28
def operate(f:(Int,Int) => Int) ={
f(4,4)
} //> operate: (f: (Int, Int) => Int)Int
def greeting() =(name:String) => {"hello"+" "+name}
greeting() ("123")
def tr(x:Int,y:Int)=x+y
operate(tr)
大家先用这些例子玩一玩吧,感觉看不到例子的话,还是很难理解这个的奥妙的
f(4,4)
} //> operate: (f: (Int, Int) => Int)Int
def greeting() =(name:String) => {"hello"+" "+name}
greeting() ("123")
def tr(x:Int,y:Int)=x+y
operate(tr)
大家先用这些例子玩一玩吧,感觉看不到例子的话,还是很难理解这个的奥妙的
2016-07-28