Find a train platform
Before you start this intermediate track
Typed functions and maps. The lessons use named parameters and nullable values.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Predict the result.
Which platform label is printed?
void main() { final platforms = {'cedar': 'B4', 'harbor': 'D2'}; final destination = 'harbor'; final platform = platforms[destination]; print(platform);}Each mission is a complete Dart 3 program with its own main function. Run one at a time with dart run. Only the built-in dart:core library is used; Flutter is not required.
Review the lesson
A map connects keys to values. This station map connects destination names to platform labels, so the program can look up a destination selected by the traveler. Square brackets use the value inside destination as the key. The program prints the matching label without depending on the map entry order.