Skip to content

Instantly share code, notes, and snippets.

@topex-psy
Last active March 24, 2023 02:48
Show Gist options
  • Save topex-psy/a1375f4527289e1173a7d0d4de86b24d to your computer and use it in GitHub Desktop.
Save topex-psy/a1375f4527289e1173a7d0d4de86b24d to your computer and use it in GitHub Desktop.
Dart 3. Control Flow Statements

Dart 3. Control Flow Statements

Created with <3 with dartpad.dev.

void main() {
String? nama = "Taufik";
const umur = 20;
double? tinggi = 175.436537;
bool? isMarried;
bool isHasJob = true;
final jobs = <String>["Programmer", "Web Developer", "Software Engineer"];
final bio = {
"Nama": nama ?? "Anonim",
"Umur": "$umur tahun",
"Tinggi": tinggi == null ? "-" : "$tinggi cm",
"Menikah": isMarried == null ? "-" : isMarried ? "Sudah" : "Belum",
"Bekerja": isHasJob ? "Ya" : "Tidak",
};
print("Selamat Datang, ${nama ?? "Tamu"}!");
bio.forEach((key, value) {
print("$key\t: $value");
});
for (final job in jobs) {
print(job);
}
int year = 2000;
while (year <= 2023) {
print(year);
year++;
}
for (int month = 1; month <= 12; month++) {
print(month);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment