Created
March 13, 2022 14:07
-
-
Save Deleplace/69847f9000120dd053c70a1927278e9b to your computer and use it in GitHub Desktop.
Count distinct elements
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() { | |
var items = ["a", "b", "b", "aaa", "c", "a", "d"]; | |
print('items has ${items.length} elements'); | |
var c = items.toSet().length; | |
print('items has ${c} distinct elements'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment