Closure example for lambdas

PHOTO EMBED

Sat Oct 16 2021 06:34:34 GMT+0000 (UTC)

Saved by @funcProgramming

var days = Enum.GetValues(typeof(DayOfWeek)).Cast<DayOfWeek>();
// => [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]

IEnumerable<DayOfWeek> daysStartingWith(string pattern)
	=> days.Where(d => d.ToString().StartsWith(pattern));

daysStartingWith("S") // => [Sunday, Saturday]
content_copyCOPY