Created
December 18, 2019 09:04
-
-
Save tatocaster/80dfb6184eacffebc6ffdb097a4c2c4b to your computer and use it in GitHub Desktop.
select random from set
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
import 'dart:math'; | |
void main() { | |
var _emailSet = new Set.from([ | |
'', | |
'' | |
]); | |
final _random = new Random(); | |
for (int i = 0; i < 5; i++) { | |
var element = _randomElement(_emailSet, _random); | |
_emailSet.remove(element); | |
print(element); | |
} | |
} | |
_randomElement(Set emailSet, Random random) { | |
return emailSet.elementAt(random.nextInt(emailSet.length)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment