Dart Memo : type check

Dr_Skele·2023년 1월 2일
0

Dart

목록 보기
1/5

Dart language has a type called 'dynamic'. As you can guess from it's name, it can be any type of variable. This can be a bit tricky when using it, because TypeError can be thrown.

void main() {
  dynamic something;

  if(something is String){
    print(something.length); //auto complete & no compile error
  }
}

Above code shows a simple way to avoid the problem. Also, the compiler and intellisense will know what kind of type it is inside the 'if' statement, making us easier to handle the variable.

profile
Tireless And Restless Debugging In Source : TARDIS

0개의 댓글