moors.scala

来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 13 行

SCALA
13
字号
object Test {  implicit def foo2bar(foo :Foo) :Bar = foo.bar  class Foo(val bar :Bar) {    def testCoercion ={ val a: this.type = this; a.baz /* here, foo2bar is inferred  by the compiler, as expected */}    def testCoercionThis = baz  // --> error: not found: value baz    def testCoercionThis = (this: Foo).baz  // --> error: value baz is not a  member of Foo  }    class Bar { def baz = System.out.println("baz")} }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?