Created with <3 with dartpad.dev.
Last active
March 24, 2023 02:48
-
-
Save topex-psy/a1375f4527289e1173a7d0d4de86b24d to your computer and use it in GitHub Desktop.
Dart 3. Control Flow Statements
This file contains 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() { | |
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