scala自学之路-43-隐式转换函数
object ImplicitDemo2 extends App {
var a: Int = 10
var b: Double = 10.99
b = 100
b = a
//定义一个隐式转换函数,把double转换成int
implicit def doubleToInt(x: Double) = x toInt
//可以编译通过
a = b
a = 90.99
//会有数据的精度损失
println(a)
}
...