[ create a new paste ] login | about

Link: http://codepad.org/z09oUtB4    [ raw code | output | fork ]

D, pasted on Apr 15:
import std.stdio;

class Bar {
    package long x;
    this (long x) {
        this.x = x;
    }
}

class Foo {
    package int t;

    this (int t) {
        this.t = t;
    }

    public int opEquals (Foo foo) {
        writefln("opEquals(Bar): called");
        return this.t == foo.t;
    }
    
    public int opEquals (Bar bar) {
        writefln("opEquals(Bar): called");
        return this.t == bar.x;
    }
}

void main (string[] args) {
    Foo foo = new Foo(1);

    writefln("%s", foo == new Foo(1) ? "true" : "false");
    writefln("%s", foo == new Bar(1) ? "true" : "false");
}


Output:
1
2
3
4
opEquals(Bar): called
true
opEquals(Bar): called
true


Create a new paste based on this one


Comments: