Creating your own Enumerables

Jul 16, 2012 at 3:04 PM

I'd like to create my own class which is enumerable. In other words, I want to be able to use it in $.Enumerable.From(). I've looked at the source code for Linq.js, but I still wanted to ask if there is a "recommended" way of accomplishing this. 

By the way, the enumerable class I want to create is a HashSet. (Adding ToHashSet() would be a nice addition to Linq.js!)

Thanks.

Coordinator
Jul 18, 2012 at 11:18 AM

Best is class have "length" field.
However, if class cannot have length like a infinity list then cannot use Enumerable.From.
In that case, class inherit Enumerable and implement GetEnumerator.

HashSet is a good idea.
I want you to substitute it for the time being in Dictionary.
But I examine it.