I found a little script that I understand fully. I've got a string with *1 -2 5 40*
for example. It reads the input string, splits it into a temporary array. Then this array is parsed and each element is transformed into an integer. The whole thing is order to give the nearest integer to zero.
But what I don't understand is the notation Select(int.Parse)
. There is no lambda expression here and the method int.Parse
isn't called with brackets. Same with the OrderBy(Math.Abs)
Thank you in advance
var temps = Console.ReadLine().Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);
var result = temps.Select(int.Parse)
.OrderBy(Math.Abs)
.ThenByDescending(x => x)
.FirstOrDefault();