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학점"); } }
2. 삼항 연산자
void main() { int point = 60; print(point >= 60 ? "합격" : "불합격"); }
3. null 대체 연산자
void main() { String? username = null; print(username); print(username ?? "홍길동"); }
void main() { String? username = null; print(username); print(username ?? "홍길동"); String n = (username ?? "홍길동"); print(n); }
Share article