Dart Language Guide
  • Dart Language Guide (한국어)
  • LANGUAGE GUIDE
    • A basic Dart program
    • Important concepts
    • Keywords
    • Variables
    • Built-in types
      • Numbers
      • String
      • Booleans
      • Lists
      • Set
      • Maps
  • Functions
    • Parameters
    • The main() function
    • Functions as first-class objects
    • Anonymous functions
    • Lexical scope
    • Lexical closures
    • Testing functions for equality
    • Return values
    • Generators
Powered by GitBook
On this page
Edit on GitHub
  1. Functions

The main() function

PreviousParametersNextFunctions as first-class objects

Last updated 2 years ago

The main() function

모든 앱은 최상위 main() 함수를 가져야합니다. 이 함수는 앱의 진입점(entrypoint) 역할을 합니다. main() 함수는 void를 반환하며, 인자로 선택적으로 List<String>을 받을 수 있습니다.

다음은 main() 함수의 예제입니다.

void main() {
  print('Hello, World!');
}

아래는 인자를 받는 command-line 앱의 main() 함수의 예시입니다.

// Run the app like this: dart args.dart 1 test
void main(List<String> arguments) {
  print(arguments);

  assert(arguments.length == 2);
  assert(int.parse(arguments[0]) == 1);
  assert(arguments[1] == 'test');
}

command-line 인자를 정의하고 파싱하기 위해 를 사용할 수 있습니다.

args 라이브러리