Flutter - Dart -流程控制 ifelse whil
2024-07-07 本文已影响0人
rainy66
if
if (true) {
print('maybe1');
}
if else
int a = 1;
String b = ' ';
if (a == 1) {
b = 'maybe2';
} else {
b = 'maybe3';
}
print(b);
for
for (var i = 0; i < 10; i++) {
print(i);
if (i == 1) {
break;
}
if (i == 2) {
continue;
}
}
while
int day = 0;
while (day < 7) {
print(day);
day++;
if (day == 2) {
break;
}
if (day == 4) {
continue;
}
}
do while
int time = 0;
do {
print(time);
time++;
if (time == 3) {
break;
}
if (time == 5) {
continue;
}
} while (time < 7);
switch
String date = 'Mon';
switch (date) {
case 'Mon':
print(date);
break;
case 'Tus':
print(date);
break;
case 'Wes':
case 'Thr':
case 'Fti':
print(date);
break;
default:
print(date);
}