Create an object/Native demonstration: Difference between revisions

Updated D entry
(→‎{{header|Ruby}}: {{works with|Ruby|1.9}} for KeyError)
(Updated D entry)
Line 13:
TV[TK] standard, current;
 
this(TV[TK] default_) pure /*nothrow*/ @safe {
this.standard = default_;
this.current = default_.dup;
Line 24:
}
 
void clear() /*pure /*nothrow*/ @safe {
current = standard.dup;
}
Line 31:
void main() {
import std.stdio;
auto d = DefaultAA!(string, int)(["a": 1, "b": 2].DefaultAA!(string, int);
 
writeln(d).writeln; // ["a":1, "b":2]
d["a"] = 55; d["b"] = 66;
writeln(d).writeln; // ["a":55, "b":66]
d.clear();
writeln(d).writeln; // ["a":1, "b":2]
d["a"] = 55; d["b"] = 66;
writeln(d["a"]).writeln; // 55
d.remove("a");
writeln(d).writeln; // ["a":1, "b":66]
}</lang>
{{out}}