Last active
August 30, 2020 08:33
-
-
Save amondnet/de5188849919adeec1b5d6d67d15b9e4 to your computer and use it in GitHub Desktop.
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
변수를 선언할 때는 `변수타입 변수명;` 의 형태로 작성합니다. | |
변수에 값을 할당할 떄는 `변수명 = 변수값` 의 형태로 작성합니다. |
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
var a; | |
var b; | |
var c; | |
var d; | |
//TODO: updateSomeVars 의 내용을 작성하세요 | |
void updateSomeVars() { | |
//TODO: 변수 a 에 정수 100 을 할당하세요 | |
//TODO: 변수 b 에 부동소수점 100.1 읋 할당하세요 | |
//TODO: 변수 c 에 참 값을 할당하세요 | |
//TODO: 변수 d 에 문자열(홍길동)을 할당하세요 | |
} |
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() { | |
a = 100; | |
b = 100.1; | |
c = true; | |
c = '홍길동'; | |
} |
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
final errs = <String>[]; | |
void main() { | |
try { | |
updateSomeVars(); | |
check('a', a, 100); | |
check('b', b, 100.1); | |
check('c', c, true); | |
check('d', d, '홍길동'); | |
} catch (e) { | |
errs.add( | |
'Tried run updateSomeVars and received an exception: ${e.runtimeType}.'); | |
} | |
if (errs.isEmpty) { | |
_result(true); | |
} else { | |
_result(false, errs); | |
} | |
} | |
void check(String name, dynamic value, dynamic expected) { | |
if (value == null) { | |
errs.add('$name 은(는) null 입니다.'); | |
} | |
if (value.runtimeType != expected.runtimeType) { | |
errs.add('$name 은(는) ${expected.runtimeType.toString()}가 아닙니다'); | |
} | |
if (value != expected) { | |
errs.add('$name 은(는) $expected 가 아닙니다'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment