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() { | |
const int budget = 1000; | |
// budget = 1100; // 이렇게 변경하려고 하면 오류 발생! | |
const pi = 3.14159; // 항상 같은 값 | |
print(pi); | |
} |
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() { | |
final int age = 25; | |
// age = 30; // 이렇게 변경하려고 하면 오류 발생! | |
final now = DateTime.now(); // 실행 중에 현재 시간을 할당할 수 있음 | |
print(now); // 프로그램 실행 시점의 시간 출력 | |
} |
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() { | |
var height = 175; | |
var isTall = height >= 180; | |
var isHandsome = true; | |
print(isTall); // false | |
print(isHandsome); // true | |
print(isTall || isHandsome); // true | |
print(isTall && isHandsome); // false |
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() { | |
var added = 1 + 2; | |
print(added); // 3 | |
var subtracted = 3 - 4; | |
print(subtracted); // -1 | |
var multiplied = 4 * 2; | |
print(multiplied); // 8 |
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() { | |
// 익명 함수 정의 | |
var multiply = (int a, int b) { | |
return a * b; | |
}; | |
// 익명 함수 호출 | |
print(multiply(3, 4)); // 출력: 12 | |
} |
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() { | |
var brands = ['nike', 'adidas', 'fila']; | |
brands.map((String e) { | |
return e.toUpperCase(); // NIKE, ADIDAS, FILA | |
}).forEach((e) { | |
print(e); | |
}); | |
brands.map((e) => e.toUpperCase()).forEach((e) => print(e)); |
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
// bool isOdd(int number) { | |
// return number % 1 == 0; | |
// } | |
bool isOdd(int number) => number % 2 == 1; | |
void main() { | |
print(isOdd(3)); | |
} |
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 greetings({ | |
required String name, | |
required int age, | |
String job = '홈프로텍터', | |
String? pet, | |
}) { | |
print('안녕하세요, 제 이름은 $name이고 $age세입니다. 저는 $job(으)로 활동하고 있습니다.'); | |
if (pet != null) { | |
print('애완동물은 $pet을(를) 기릅니다'); |
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 greetings(String name, int age, [String job = '홈프로텍터', String? pet]) { | |
print('안녕하세요, 제 이름은 $name이고 $age세입니다. 저는 $job(으)로 활동하고 있습니다.'); | |
if (pet != null) { | |
print('애완동물은 $pet을(를) 기릅니다'); | |
} | |
} | |
void main() { | |
greetings("경수", 30); |
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 greetings(String name, int age) { | |
print('안녕하세요, 제 이름은 $name이고 $age세입니다.'); | |
} | |
void main() { | |
greetings('옥순', 30); | |
} |
NewerOlder