scala 函数(柯理化)
Posted liqingan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scala 函数(柯理化)相关的知识,希望对你有一定的参考价值。
scala 函数柯理化 , 上代码 , 一目了然
object Function {
def main(args: Array[String]) {
val name ="zhangsan"
val id ="001"
val first = showInfo(name)
val second = first(id)
second("play baseketball")
second("swiming ")
showInfo1(name)(id)("play baseketball")
showInfo1(name)(id)("swimming")
}
/**
* 函数柯里化
* @param name
* @param id
* @param hobby
*/
def showInfo1(name:String)(id:String)(hobby:String){
println(name+id+hobby)
}
/**
*
* 实质
* @param name
* @return
*/
def showInfo(name:String)=(id:String)=>(hobby:String)=>{
println(name+id+hobby)
}
}
object Function {
def main(args: Array[String]) {
val name ="zhangsan"
val id ="001"
val first = showInfo(name)
val second = first(id)
second("play baseketball")
second("swiming ")
showInfo1(name)(id)("play baseketball")
showInfo1(name)(id)("swimming")
}
/**
* 函数柯里化
* @param name
* @param id
* @param hobby
*/
def showInfo1(name:String)(id:String)(hobby:String){
println(name+id+hobby)
}
/**
*
* 实质
* @param name
* @return
*/
def showInfo(name:String)=(id:String)=>(hobby:String)=>{
println(name+id+hobby)
}
}
以上是关于scala 函数(柯理化)的主要内容,如果未能解决你的问题,请参考以下文章