Hacker News new | past | comments | ask | show | jobs | submit login

Nice. I've used extension methods from time to time but not in this way. Could prevent you from writing if foo != null a lot if you have an extension method by doing: public static bool Exists(this Foo foo) { return foo != null; }

So then you can say if(foo.Exists()) { foo.bar(); }

Or make Exists return an instance of Foo (foo if not null, a new Foo if not) and go with foo.Exists().bar();




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: