Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active March 28, 2017 19:41
Show Gist options
  • Save controlflow/946cd12821545c37c9c80b8e454e9342 to your computer and use it in GitHub Desktop.
Save controlflow/946cd12821545c37c9c80b8e454e9342 to your computer and use it in GitHub Desktop.
while (GetSomethingToUseTwice() is var x
&& x != null
&& UseOnceMore(x)
&& AndMore(x))
{
// ...
}
// C#'s 'is var t' var pattern to introduce a name for expression where statements are not allowed
// is somewhat similar to 'let-in' from functional languages:
let f () =
someFunction
"firstArg"
secondArg
(let x = getSomethingToUseTwice()
in useOnceMore x (andMore x))
fourthArg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment