Skip to content

Commit

Permalink
Fix spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Jan 7, 2024
1 parent b9e5d4a commit e7998f0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Allows lambdas to implement interfaces and to target generic methods to create z
```csharp
interface IAction
{
//Single method the lambda can implement
//Single method the lambda can implement
void Invoke();
}

static class Consumer
{
//The actual lambda target, generic to allow struct specialization
//The actual lambda target, generic to allow struct specialization
static void Run<T>(T action)
where T : IAction //Generic constraint to specify the interface
{
action.Invoke();
}

//C# doesn't support the syntax so use dummy method
//C# doesn't support the syntax so use dummy method
static void Run(Action a) => a(); //Or you can throw to catch any problems
}

Expand All @@ -30,14 +30,14 @@ static partial class Sample
{
int param = 10;

//Targets actually Consumer.Run<T>
//Targets actually Consumer.Run<T>
Consumer.Run(() =>
{
Console.WriteLine($"First: {param}");

param = 20;

//Targets actually Consumer.Run<T>
//Targets actually Consumer.Run<T>
Consumer.Run(() =>
{
Console.WriteLine($"Second: {param}");
Expand Down

0 comments on commit e7998f0

Please sign in to comment.