Skip to content

proposal: spec: add Nullable constraint #53656

@MrTravisB

Description

@MrTravisB
func foo[T any](param T) {
	if param == nil {
		// do a thing
	}
}

This is invalid

invalid operation: cannot compare param == nil (mismatched types T and untyped nil)

Would be nice to have a nullable constraint so that the following could be done

func foo[T Nullable](param T) {
	if param == nil {
		// do a thing
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions