Variable assignment in “if” condition in Dlang

H. S. Teoh hsteoh at quickfur.ath.cx
Sun May 3 15:13:48 UTC 2020


On Sun, May 03, 2020 at 02:53:21PM +0000, Baby Beaker via Digitalmars-d-learn wrote:
> How can I assign a variable in “if” condition in Dlang?

	if (auto obj = someFunction(...)) {
		// use obj here, it's guaranteed to be
		// true/non-null/etc.
	}


T

-- 
EMACS = Extremely Massive And Cumbersome System


More information about the Digitalmars-d-learn mailing list