Created
September 16, 2018 13:34
-
-
Save emanuelefirmani/e378c4bceb37bc1cbd25f38e516911d6 to your computer and use it in GitHub Desktop.
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
| private IEnumerable<string> FormatNonFunctional(List<string> shoppingList) | |
| { | |
| var index = 0; | |
| var result = new List<string>(); | |
| _outp.WriteLine(shoppingList.Count.ToString()); | |
| return shoppingList.Select(item => (index++).ToString() + item.Capitalize()); | |
| } |
Author
Author
The body of the lambda expression can be replaced by:
item.Capitalize().PrependNumeration(index++)
Author
Even better:
private IEnumerable<string> FormatFunctional(List<string> shoppingList, int startingIndex = 0)
=> shoppingList.Select(item => shoppingList.Select(item => item.Capitalize().PrependNumeration(startingIndex++)).ToList();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@arialdomartini, does it solve?