I received feedback one of my posts that a line of code was too complicated for average to starting programmers:
private static IEnumerable<list<int>> permutations(int size)
The interesting thing about this line is I did not write it.
I did not even write all of the Line that calls it:
foreach (List<int> permutation in permutations(9))
I do recall my thinking as I was creating it. I was thinking I want to loop over a bunch of collection of permutations dealing so I typed in the first letters of 'foreach'. Intellisense kicked in and suggested the 'foreach' snippet. I hit tab twice to accept it and the following code was generated:
foreach (object var in collection_to_loop)
{
}
The snippet highlighted the snippet literals to be replaced. I had not thought what type a permutation would best be. So I used a list of integers 'List
What is interesting is how the compiler has moved from nagging us about our mistakes after the fact to proactively helping us write code. So I stop worrying about the compiler and it know worries about me.
No comments:
Post a Comment