Skip to content

Instantly share code, notes, and snippets.

@bradyt
Created June 29, 2019 02:42
Show Gist options
  • Save bradyt/52e330a6a70348c6229ee14e45d8abe6 to your computer and use it in GitHub Desktop.
Save bradyt/52e330a6a70348c6229ee14e45d8abe6 to your computer and use it in GitHub Desktop.
void main() {
var thing = ['a:b', 'c:d:e'];
var subaccounts = Set<String>();
for (var t in thing) {
while (t.lastIndexOf(':') != -1) {
t = t.substring(0, t.lastIndexOf(':'));
subaccounts.add(t);
}
}
print(thing.toSet().union(subaccounts).toList()..sort());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment