Flutter ● ○ ○ Dart 3.6

Kodebits Day 26: Set Membership Check

May 20 2026
Practice collections with a short dart challenge.

What does this print?

void main() {
  final s = {4, 5};
  print(s.contains(4));
  print(s.length);
}


Try it in the online Dart Playground →

[spoiler title="Solution"]

Answer:

true
2

Explanation:

The set `{4, 5}` contains two elements. `contains(4)` returns `true` because 4 is in the set, and `length` returns 2.

[/spoiler]


Further Reading