Closed
Description
Issue Checklist
- I have properly named my enhancement
- I have checked the Issues/Discussions pages to see if my enhancement has already been suggested
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;
}
Activity