Skip to content

Instantly share code, notes, and snippets.

@zakky-dev
Created January 28, 2014 14:41
Show Gist options
  • Save zakky-dev/8668832 to your computer and use it in GitHub Desktop.
Save zakky-dev/8668832 to your computer and use it in GitHub Desktop.
opOpAssignで遊んでみる
import std.stdio;
class Test {
private string _value;
this(string value) {
this._value = value;
}
Test opOpAssign(string op)(Test delegate(string) test) if(op == ">>") {
return test(this._value);
}
}
void main() {
auto l = new Test("left value");
auto r = new Test("right value");
auto res = l >>= v => r >>= v1 => l;
res._value.writeln; // left value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment