Created
September 14, 2020 23:53
-
-
Save ssippe/dcf36ce77bf3bfdd18733ae0dcf92e2c to your computer and use it in GitHub Desktop.
List generation with optional members and immutable variables
This file contains 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
static IReadOnlyList<int> GenerateList(int option) | |
{ | |
IEnumerable<int> F() | |
{ | |
if (option > 0) | |
yield return 1; | |
if (option > 1) | |
yield return 2; | |
if (option > 3) | |
yield return 3; | |
} | |
return F().ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment