Created
October 22, 2020 17:22
-
-
Save timsneath/6f1e43d6cefe99b4d52913086dc32379 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void honk(int? loudness) { | |
if (loudness == null) { | |
// No loudness specified, notify the developer | |
// with maximum loudness. | |
_playSound('error.wav', volume: 11); | |
return; | |
} | |
// Loudness is non-null, let's just clamp it to acceptable levels. | |
_playSound('honk.wav', volume: loudness.clamp(0, 11)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment