if ((auto wText = cast<TextWidget>(w)) !is null)
wText.SetColor(col);
else if ((auto wButton = cast<ButtonWidget>(w)) !is null)
wButton.SetColor(col);
Syntax suggestion for if statements
I'll think about it.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I don't actually know a language where the above is valid but I can imagine that some exist. However, it may be worth considering that C++17 introduces a similar but more consistent and, to me, far better looking syntax, for if and switch statements, similar to that of for loops:
if (auto it = m.find(10); it != m.end()) {
return it->size();
}
funny. I had considered exactly the analogy of declaring variables in for() loops to accomplish the suggestion that Ansjh brought up. It makes me pleased to know that this same idea has already been introduced in C++17.
I agree that the syntax introduced in C++17 is better and also consistent with the already existing syntax in for-loops.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game