Expression evaluation order in if statement

Aarti_pl aarti at interia.pl
Thu Aug 23 02:21:01 PDT 2007


Hello!

Can I use if expression in following way, or is it an error?:

void func(char[] str) {
	if (str !is null && str=="somestring") {
		... some code ...
	}
}

or should I rather use:
void func(char[] str) {
	if (str !is null)
		if (str=="somestring") {
			... some code ...
		}
}

The second way is more explicit and makes code unreadable soon...

I can find clear answer in docs...

BR
Marcin Kuszczak
(Aarti_pl)


More information about the Digitalmars-d-learn mailing list