digitalmars.D.learn - pure vs immutable
- Jack Applegame (14/14) Nov 19 2015 I believe that object constructed with pure constructor should be
- Jack Applegame (2/2) Nov 19 2015 Heh
I believe that object constructed with pure constructor should be
implicitly convertible to immutable. It is, but only for default
constructor.
class Foo {
string s;
this() pure {
s = "fpp";
}
this(string p) pure { s = p; }
}
void main() {
auto foo1 = new immutable Foo(); // compiles
auto foo2 = new immutable Foo("bar"); // fails
}
Nov 19 2015
Heh
immutable Foo foo2 = new Foo("bar"); // compiles
Nov 19 2015








Jack Applegame <japplegame gmail.com>