Scala 隐式参数示例:代码执行结果
代码示例:
object implicitDemo {
def main(args: Array[String]): Unit = {
implicit val name = 'scala'
def hello(implicit cont: String = 'ok') = { println('hi ' + cont) }
hello
}
}
执行结果:
hi scala
原文地址: https://www.cveoy.top/t/topic/j72w 著作权归作者所有。请勿转载和采集!