闭包,和js中的闭包一样,返回值依赖于声明在函数外部的一个或多个变量,那么这个函数就是闭包函数. val i: Int = 20 //函数func的方法体中使用了在func外部定义的变量 那func就是个闭包函数 val func = (x: Int) => x + i 柯里化(Currying)指的是把原来接受多个参数的函数变换成接受一个参数的函数过程,并且返回接受余下的参数且返回结果为一个新函数的技术.柯里化并不是scala特有的,js中也有. package com.zy.scala ob…
隐士转换是Scala提供的一种语法糖 Implicit definitions are those that the compiler is allowed to insert into a program in order to fix any of its type errors. Sacla隐士转换的规则 Marking rule: Only definitions marked implicit are available Scope rule: An inserted implicit…