Skip to content

Instantly share code, notes, and snippets.

@Mastersam07
Last active March 30, 2020 23:34
Show Gist options
  • Select an option

  • Save Mastersam07/fbca98caf45a63bb3bb3673df1f9940e to your computer and use it in GitHub Desktop.

Select an option

Save Mastersam07/fbca98caf45a63bb3bb3673df1f9940e to your computer and use it in GitHub Desktop.
a function that returns the index of a particular resistor color
void main() {
print(getIndex('Red'));
}
// a function that returns the index of a particular resistor color
// taking the color as argument
int getIndex(color) {
var dict = {
'Black': 0,
'Brown': 1,
'Red': 2,
'Orange': 3,
'Yellow': 4,
'Green': 5,
'Blue': 6,
'Violet': 7,
'Grey': 8,
'White': 9
};
return dict[color];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment