Created
January 13, 2021 06:22
-
-
Save tranductam2802/61c439aadc0124bb0b6545c127291505 to your computer and use it in GitHub Desktop.
02. Dart method (for test)
This file contains hidden or 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
Assign data to result |
This file contains hidden or 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
/// Update value for result | |
void plus(int a, int b, Result result) { | |
} | |
class Result { | |
int value = 0; | |
} | |
// Testcase | |
// void main() { | |
// try { | |
// final result = Result(); | |
// final str = plus(2, 3, result); | |
// if (result == 5) { | |
// _result(true); | |
// } else if (result == 0) { | |
// _result(false, ['Test failed. It looks like you forgot assign data!']); | |
// } else { | |
// _result(false, ['That\'s not quite right. Keep trying!']); | |
// } | |
// } catch (e) { | |
// _result(false, ['Tried calling plus(2, 3), but received an exception: ${e.runtimeType}']); | |
// } | |
// } |
This file contains hidden or 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 plus(int a, int b, Result result) { | |
result.value = a + b; | |
} |
This file contains hidden or 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() { | |
try { | |
final result = Result(); | |
final str = plus(2, 3, result); | |
if (result == 5) { | |
_result(true); | |
} else if (result == 0) { | |
_result(false, ['Test failed. It looks like you forgot assign data!']); | |
} else { | |
_result(false, ['That\'s not quite right. Keep trying!']); | |
} | |
} catch (e) { | |
_result(false, ['Tried calling plus(2, 3), but received an exception: ${e.runtimeType}']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment