Skip to content

Let types declare default values, and make them available on type variables. #1227

Open
@Silentdoer

Description

@Silentdoer

please consider following code, and it's comment.

class Foo<T> {
// T k = default(T);
  T k;

  int m;

  // will tips: Non-nullable instance field 'k' must be initialized.
  // but if k is T?, and Foo<int?>, k's type will be int?? is very odd.
  // so i think may be support default keyword, then T k = default(T), and not allow T? k statement.
  Foo(int a, T b) {
    this.m = a * 2;
    this.k = b;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions