Skip to content

Instantly share code, notes, and snippets.

@jasonrdsouza
Last active June 9, 2020 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrdsouza/03a14b8484f977c1a6ccabac47494baf to your computer and use it in GitHub Desktop.
Save jasonrdsouza/03a14b8484f977c1a6ccabac47494baf to your computer and use it in GitHub Desktop.
Dartpad Gist to Choose a Random Winner
import 'dart:math';
List<String> contestants = [
'Jason',
'Matt',
'Gabe',
'Ishan',
'Luis',
'Katie',
'Andrew',
];
String chooseWinner(List<String> contestants) {
int choice = Random.secure().nextInt(contestants.length);
return contestants[choice];
}
void main() {
print("The winner is ${chooseWinner(contestants)}");
}
@jasonrdsouza
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment