Skip to content

Instantly share code, notes, and snippets.

@rstropek
Last active June 6, 2021 14:08
Show Gist options
  • Save rstropek/979426774d588714269b63828392a73d to your computer and use it in GitHub Desktop.
Save rstropek/979426774d588714269b63828392a73d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
var heroes = new List<Hero>
{
new("Superman", int.MaxValue),
new("The Tick", 10),
};
if (heroes is { { MaxJumpDistance: > 1000 }, { MaxJumpDistance: < 100, Name: var snd } })
{
Console.WriteLine($"First can fly, second ('{snd}') cannot jump very far");
}
class Hero
{
public string Name;
public int MaxJumpDistance;
public Hero(string name, int maxJumpDistance)
=> (Name, MaxJumpDistance) = (name, maxJumpDistance);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment