I was wondering if there was a way to put this on one line?
if (auto r = getGlobalObjectByName(word)) r->doSomething; // This works fine
if (!auto r = getGlobalObjectByName(word)) r->doSomething; // It says "expected an expression
if (auto r = getGlobalObjectByName(word) == false) r->doSomething; // Also doesn't work.
I also tried surrounding it extra brackets, doesn't seem to work. I find this really convenient doing it on one line.
Aucun commentaire:
Enregistrer un commentaire