Created
April 17, 2020 07:16
-
-
Save iampawan/76a5c019175c0819961949c4351feab9 to your computer and use it in GitHub Desktop.
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() { | |
final myNumbers = [11,25,87,127,10,55,67,38,52,119,131,99]; | |
// Rookie Way | |
num sum = 0; | |
for (int i = 0; i < myNumbers.length; i++) { | |
sum += myNumbers[i]; | |
} | |
print(sum); // prints 821 | |
//Handy Way | |
print(myNumbers.reduce((curr,next)=>curr+next)); // prints 821 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment