글

라벨이 언어인 게시물 표시

[Flutter] Dart 문법설명 (try catch, rethrow, finally, assert, forEach, for in, continue, break)

Dart 문법설명을 해보자 중요해보이는 문법 위주로 정리한다. try catch //try catch try { var num = null; num ++ ; } catch (e) { print( 'e : ${e.toString()} ' ) ; } print( 'finish!' ) ; => e : NoSuchMethodError: method not found: '$add' on null finish! catch 에 잡힌후, 다음 구문 실행 됨. try catch rethrow //try catch rethrow try { var num = null; num ++ ; } catch (e) { print( 'e : ${e.toString()} ' ) ; rethrow; } print( 'finish!' ) ; => e : NoSuchMethodError: method not found: '$add' on null Uncaught TypeError: Cannot read properties of null (reading '$add')Error: TypeError: Cannot read properties of null (reading '$add') rethrow를 만나고 프로그램 정지됨. try catch finally //try catch finally try { var num = null; num ++ ; } catch (e) { print( 'e : ${e.toString()} ' ) ; rethrow; } finally { print( 'print finally!' ) ; } print( 'finish!' ) ; => e : NoSuchMethodError: method not found: '$add' on null print fi...