Skip to content

Instantly share code, notes, and snippets.

@DavidArno
Last active July 14, 2017 13:25
Show Gist options
  • Save DavidArno/a09aa73764231c74077f0c4ffac5cc2d to your computer and use it in GitHub Desktop.
Save DavidArno/a09aa73764231c74077f0c4ffac5cc2d to your computer and use it in GitHub Desktop.
Using C# 7 features, throw expressions & x is T y
public Bar DoSomething(Foo uncheckedFoo) =>
uncheckedFoo is Foo foo
? DoSomething2(foo)
: throw new ArgumentNullException(nameof(uncheckedFoo));
private Bar DoSomething2(Foo foo) => // foo is definitely set here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment