var global = 2; //global scope
void main() { //function scope
//Ternary operator - ?:
print(5 > 3 ? 'true' : 'false'); // true
//if-else
if (global.isEven) { //local scope
print('even');
} else if (global.isOdd) {
print('odd');
} else {
print('error');
}
//switch (enum, int, String or compile-time constant)
var pos = Position.first; //enum value
print(pos.index); //index of enum value
switch (pos) {
case Position.first:
print('gold');
break;
case Position.second:
print('silver');
break;
default:
print('bronze');
}
}
//enums
enum Position { first, second, third }
суббота, 3 апреля 2021 г.
Switchers
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий