Am Mon, 03 Feb 2014 10:25:17 +0000 schrieb "Chris" <[email protected]>:
> MyStruct(T) {
> T[T] attributes;
> // ....
> public auto getAttribute(T attr) {
> if (!(attr in attributes)) {
> return null; // Doesn't work for numbers!
> }
> return attributes[attr];
> }
> }
>
> void main() {
> auto myStr = MyStruct!int(0); // Error
> }
MyStruct(T) {
T[T] attributes;
// ....
public auto getAttribute(T attr) {
return attr in attributes;
}
}
There you go.
--
Marco
