Using enum constant from different modules

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 10 16:08:51 PDT 2014


On Thursday, 10 July 2014 at 20:59:17 UTC, simendsjo wrote:
> Strings behaves a bit odd with is(). The following passes:
>
> import std.stdio;
> void f(string a, string b) {
>     assert(a is b); // also true
> }
> void main() {
>     string a = "aoeu";
>     string b = "aoeu";
>     assert(a is b); // true
>     f(a, b);
>     writeln("passed");
> }

```d
import std.stdio;
void f(string a, string b) {
    writeln("a: ", a.ptr, ", b: ", b.ptr);
    assert(a is b); // also true
}
void main() {
    string a = "aoeu";
    string b = "aoeu";
    writeln("a: ", a.ptr, ", b: ", b.ptr);
    assert(a is b); // true
    f(a, b);
    writeln("passed");
}
```

Output:
```
a: 4210A0, b: 4210A0
a: 4210A0, b: 4210A0
passed
```

Seems legit to me.


More information about the Digitalmars-d-learn mailing list