Skip to content

Instantly share code, notes, and snippets.

@dirisujesse
Last active October 23, 2022 20:50
Show Gist options
  • Save dirisujesse/c78593dd0c8c76614b77041f1d3fb5fb to your computer and use it in GitHub Desktop.
Save dirisujesse/c78593dd0c8c76614b77041f1d3fb5fb to your computer and use it in GitHub Desktop.
Modulo Use Example
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