조건문

송민경's avatar
Apr 05, 2024
조건문

1. if문

void main() { int point = 90; if (point >= 90) { print("A학점"); } else if (point >= 80) { print("B학점"); } else if (point >= 70) { print("C학점"); } else { print("F학점"); } }
notion image
 

2. 삼항 연산자

void main() { int point = 60; print(point >= 60 ? "합격" : "불합격"); }
notion image
 

3. null 대체 연산자

void main() { String? username = null; print(username); print(username ?? "홍길동"); }
notion image
void main() { String? username = null; print(username); print(username ?? "홍길동"); String n = (username ?? "홍길동"); print(n); }
notion image
Share article

vosw1