标签:any str else java == cal string message bsp
想知道什么差别,把代码复制下来运行看结果
// 1 1 2 3 5 8 13 def f(x:Int) :Int= { if(x==0) return 1 else if(x==1) return 1 else f(x-1)+f(x-2) } println(f(5)) // val ff =(cur: Int,x: =>Int) => // { // if(cur==0) // 1 // else if(cur==1) // 1 // else // // { // // x(cur-1)+x(cur-2) // // } // 0 // } def funcResult1(message:String) :AnyRef = (name:String)=>println(message+" : "+name) //原先写法 def fimcResult1(message:String,name:String) //{println(message+" : "+name)} funcResult1("Hello")//("Java") val result = funcResult1("Hello")//与前面的调用方法相同 //result("java") println(result); val x = funcResult1 println(x("12312"))
标签:any str else java == cal string message bsp
原文地址:https://www.cnblogs.com/shuiyonglewodezzzzz/p/9315675.html