IIf() May Get a Dose of Legitimacy
Paul Vick announced a possible change for VB 9.0, this change would give the IIF method the legitimacy it has long deserved. The issue with IIf is that it’s not a short-circuit operator, which can severely limits its usefulness. Take the following example, that will throw an exception if obj is Nothing:
IIf(obj IsNot Nothing, obj.Property1, String.Empty)
Since IIf() is just a normal method, all parameters will be evaluated, regardless of weather obj is Nothing. This change would make IIf a true part of the language, a true ternary operator, instead of just another method.
IIf is largely avoided due to performance issues, and its limited usefulness for the reason above. Now that IIf may function as a true operator (though still wrapped in the cloak of a method), it will be a truly useful part of the language, one that I’ve long wished for. I’ve always been a fan of IIf, it’ll be nice to be able to use it again, without the overheard and issues that has long went with its use.
Mr. Vick is still soliciting comments on this change, so now is the time to make your opinion known.
Welcome!
I am a software developer, currently located in Eastern Tennessee. While my primary focus is creating software on Microsoft's .NET stack, I also write about other technologies and development in general.Search
Articles
- January 2012
- October 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- August 2010
- July 2010
- June 2010
- April 2010
- February 2010
- December 2009
- October 2009
- July 2009
- June 2009
- December 2008
- November 2008
- October 2007
- August 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006









