Damn C++ and damn D!

Michel Fortin michel.fortin at michelf.com
Sun Feb 5 18:27:09 PST 2012

On 2012-02-05 16:25:33 +0000, Jose Armando Garcia <jsancio at gmail.com> said:

> On Sun, Feb 5, 2012 at 2:13 PM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> Make it a function.
> I agree that in theory that you can do all this stuff in D but the
> reality is that developers are lazy and end up fighting the language.

Make it a function literal:

immutable variable = {
	if (boolean_condition)
		return 1
		return 2;

The extra () at the end calls the literal immediately so that variable 
is assigned the result.

Michel Fortin
michel.fortin at michelf.com

More information about the Digitalmars-d mailing list