Scala implicit 操作04
package scala_learn.demo12_Implicit
/**
* Created by liguohua on 2017/3/1.
*/
class O5_ImplicitDemo {
}
object O5_ImplicitDemo {
def main(args: Array[String]) {
val rs = 0.incr(3)
println(rs)
}
//隱式類不能是頂層類
implicit class Caculate(i: Int) {
//定義一個增強方法
def incr(i: Int): Int = i + 1
}
implicit class Pow(g: GrandF) {
def pow(): Unit ={
println("get power")
}
}
}