Skip to content

T? x = default does not work with value types? #7462

Discussion options

You must be logged in to vote

Yes. This is the expected and documented behavior in the spec. For an unconstrained type parameter, T? means "can be default".

Should there be an analyzer to warn about this?

This is very expected behavior that many libraries and apps depend on.

You could write an analyzer for your own projects, but it would not be something we could make a standard one.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by colejohnson66
Comment options

You must be logged in to vote
3 replies
@colejohnson66
Comment options

@CyrusNajmabadi
Comment options

@colejohnson66
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants