diff --git a/src/main/scala/top/fjy8018/scala/ImplicitParaApp.scala b/src/main/scala/top/fjy8018/scala/ImplicitParaApp.scala new file mode 100644 index 0000000..0758d48 --- /dev/null +++ b/src/main/scala/top/fjy8018/scala/ImplicitParaApp.scala @@ -0,0 +1,22 @@ +package top.fjy8018.scala + +/** + * F嘉阳 + * 2019-01-03 11:32 + */ +object ImplicitParaApp { + + implicit val test = "test" + + def main(args: Array[String]): Unit = { + + // 隐式参数会自动寻找方法、类内部、伴生类内类型匹配的唯一参数 + // 若外部定义了多个隐式参数则报错 + def testPara(implicit name: String): Unit = { + println(name + "...") + } + + testPara + } + +}