Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: berrybrew, the perlbrew for Windows, updated to v1.18by Jenda (Abbot) |
on Feb 17, 2018 at 01:58 UTC ( [id://1209368]=note: print w/replies, xml ) | Need Help?? |
So I looked at the C# code and I have a few comments. .Select(x => x.Split(new char[] {'.'})) is better written as .Select(x => x.Split('.')). No need to explicitly construct the array unless you have to pass the count or split options. There's no point in splitting the version and then joining it back. Just keep it. Same way as if you used the Schwartzian transform in Perl. The code has to be somewhat more talkative, in part because the IEnumerable (aka list) transformations (.Select() aka map{}, .Where() aka grep{} and so forth) are kinda lazy and sometimes you have to make sure they are applied and the result remembered. And you have to choose the data structure used to remember them. This is how I would write the code:
You do not have to specify all those types. List<int> nameLengths = new List<int>(); is equivalent to var nameLengths = new List<int>(); and it's shorter and easier to modify. Same with things like foreach (string perlName in Perls.Keys) Jenda
In Section
Perl News
|
|