Is there a way I can make the return type in getAttribute generic? null does not work with numbers.

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
}

Reply via email to