Skip to content

Instantly share code, notes, and snippets.

View gyugyu90's full-sized avatar
🎯
Focusing

Kyuhyeok Park gyugyu90

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