Issue Checklist
What is your suggestion, and why should it be implemented?
Null coalescing is a Haxe language feature that allows you to specify a fallback value if an expression is null. This would greatly improve readability of scripts that access a lot of null-able values.
Example:
// BEFORE
if (characterData != null && type == 'bf') {
PauseSubState.musicSuffix = (characterData.pauseMusicSuffix != null
&& characterData.pauseMusicSuffix != '') ? characterData.pauseMusicSuffix : PauseSubState.musicSuffix;
GameOverSubState.musicSuffix = (characterData.gameOverMusicSuffix != null
&& characterData.gameOverMusicSuffix != '') ? characterData.gameOverMusicSuffix : GameOverSubState.musicSuffix;
GameOverSubState.blueBallSuffix = (characterData.blueBallSuffix != null
&& characterData.blueBallSuffix != '') ? characterData.blueBallSuffix : GameOverSubState.blueBallSuffix;
}
// AFTER
if (type == 'bf') {
PauseSubState.musicSuffix = characterData?.pauseMusicSuffix ?? PauseSubState.musicSuffix;
GameOverSubState.musicSuffix = characterData?.gameOverMusicSuffix ?? GameOverSubState.musicSuffix;
GameOverSubState.blueBallSuffix = characterData?.blueBallSuffix ?? GameOverSubState.blueBallSuffix;
}
Issue Checklist
What is your suggestion, and why should it be implemented?
Null coalescing is a Haxe language feature that allows you to specify a fallback value if an expression is
null. This would greatly improve readability of scripts that access a lot of null-able values.Example: