Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qwertie opened this issue Jan 16, 2021 · 0 comments
Open

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

qwertie opened this issue Jan 16, 2021 · 0 comments
Labels

Comments

@qwertie
Copy link
Owner

qwertie commented Jan 16, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant