Archive for December 2008
A couple of weeks ago I was writing some code to initialize List<T> but my technique was very verbose and it seemed to be a distraction from what I was trying to do. Plus it seemed that every one else was writing about getting their func on.
So I looked back at some code that Nick Parker had written:
And tweaked it to initialize a list:
Now I can initialize a list like this:
Just for the record the Func initialization above could handle much more complex scenarios if needed. My usage is very simple.
Another variation on this is to create an extension method that does the same initialization like this:
And here is how you would use the extension method version:
Thanks to Nick Parker for some suggestions as I was working on this.
Something I would like to figure out is how to do this based on IEnumerable instead of IList. If you have ideas regarding implementing this on IEnumerable please add them as comments.
Also, if you want to see where I was using this, pull down the subversion source here: http://subversion.assembla.com/svn/solon-tools/trunk/Puzzles
I’ve almost learned Python several times in the recent past, but now I’m committing to learn it. Some of my learning resources are The Python Tutorial and Dive Into Python. What are other good online resources?
AUTHOR LAST MODIFIED DESCRIPTION
v-someone 2008-08-21 Initial Version
It’s official, we are at the end of 2008 and there are lots of good source control tools out there(some of the best are free).
You don’t need to keep putting change history comments in your source if you are using source control. If you add comments when you commit your code this will be handled for you.