Skip to content

EC#: Syntax error in Foo<T?> #133

@qwertie

Description

@qwertie

This gives a syntax error:

public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> list) where T : struct
{
	foreach (var item in list)
		if (item != null)
			yield return item.Value;
}

There are a couple of workarounds - you can use Nullable<T>, or this alternate syntax:

public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<@`'?`<T>> list) where T : struct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions