隐式转换 - 隐式方法
package com.sniper.scala.test
import java.io.File
class RichString(str:String) {
def doubleStr() = {
str + str
}
}
object RichContext {
//方法名称不影响
implicit def file2RichFile(str:String) = new RichString(str)
}
object Implicit {
def main(args:Array[String]) {
import RichContext._
println("x".doubleStr())
}
}