Last active
March 9, 2020 12:25
-
-
Save ZacharyPatten/c6e46acd39d3e1d1d19e8da9a482d303 to your computer and use it in GitHub Desktop.
An example of custom For syntax... Pretty dumb... Just messing around...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace Example | |
| { | |
| static void Main() | |
| { | |
| For (10, To: 5) | |
| ( | |
| Console.WriteLine | |
| ); | |
| } | |
| public static Action<Action<int>> For(int from, int? To = null) => | |
| x => | |
| { | |
| if (!To.HasValue) throw new ArgumentNullException(nameof(To)); | |
| else if (from > to) for (int i = from; i >= to; i--) x(i); | |
| else for (int i = from; i <= to; i++) x(i); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment