Playing with Orcas
As usual, just a set of random impressions:
- Anonymous types are annoyingly limited. You can't define arrays of anonymous types, for instnace, which can open up more options for intent revealing code.
- Linq seems to be heavily based around the idea of Expression, a lot of the stuff that is going on there revolves around Expression and operation on Expressions.
- Here is a new way to assert that a collection contains all the items that it should:
Assert.AreEqual(3, list.Intersect(new string[]{"ayende","rahien","bar"}).ToList().Count); - I am annoyed that this doesn't work, though:
Assert.AreEqual(3, list.Intersect({"ayende","rahien","bar"}).ToList().Count);Shouldn't this be handled by the collection initializer?
Comments
If Intersect is an extension method, you could define it like so:
public static bool Intersect<T>(this T value, params T[] values) {
}
Assuming <T> is a string, you could then write:
list.Intersect("scott", "guthrie")
Hope this helps,
Scott
I didn't try it, but I've read about the syntax new [] { "a", "b" }
So you don't have to write "string" anymore. This should allow creating arrays of anonymous types.
For your last bullet point, ScottGu answered over at his blog:
http://weblogs.asp.net/scottgu/archive/2007/03/08/new-c-orcas-language-features-automatic-properties-object-initializers-and-collection-initializers.aspx#1979012
man I hope that the new
[] {"a","b"} works. I am so jealous of python and rubys array literals.
-d
Comment preview