Skip to content

Instantly share code, notes, and snippets.

@run-dlang
Created April 2, 2018 11:36
Show Gist options
  • Save run-dlang/83756973012fcb4fec2660a39ffdad90 to your computer and use it in GitHub Desktop.
Save run-dlang/83756973012fcb4fec2660a39ffdad90 to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io
import std.stdio;
struct B
{
int a;
int* t;
this(int a) immutable
{
this.a = 7;
}
this(int a)
{
this.a = 10;
}
}
void main()
{
B a = immutable B(2);
writeln(a.a);
a.a = 4;
immutable B a2 = immutable B(3);
writeln(a2.a);
//a2.a = 3; // error : cannot modify
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment