Created with <3 with dartpad.dev.
Last active
October 23, 2022 20:50
-
-
Save dirisujesse/c78593dd0c8c76614b77041f1d3fb5fb to your computer and use it in GitHub Desktop.
Modulo Use Example
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 main() { | |
final indices = [0,1,2,3,4,5,6,7,8,9,10,11,12]; | |
for (final index in indices) { | |
final modulo = (index % 4).floor(); | |
String color = "unknown"; | |
switch(modulo) { | |
case 1: | |
color = "yellow"; | |
break; | |
case 2: | |
color = "blue"; | |
break; | |
case 3: | |
color = "white"; | |
break; | |
default: | |
color = "black"; | |
} | |
print("INDEX -> $index; MODULO -> $modulo; COLOR -> $color"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment