|
Scala example source code file (t3609.scala)
The Scala t3609.scala source codeobject Test extends Application { class A class B extends A def foo(x: A, y: B) = print(1) val foo = new { // def apply(x: B, y: A) = print(3) def apply = (x: B, z: B) => print(4) } foo(new B, new B) } // This code prints 1. If we remove comment, then it will print 4. // Moreover following code prints 3 (which is most strange thing): object Test2 extends Application { class A class B extends A def foo(x: A, y: B) = print(1) val foo = new { def apply(x: B, y: A) = print(3) def apply = new { def apply = (x: B, z: B) => print(4) } } foo(new B, new B) } Other Scala examples (source code examples)Here is a short list of links related to this Scala t3609.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.