From 77dc4d8b8d59a35bb239794f755257bcbf6c104d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Thu, 3 Jan 2019 16:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E5=BC=8F=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/fjy8018/scala/ImplicitParaApp.scala | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/scala/top/fjy8018/scala/ImplicitParaApp.scala 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 + } + +}