Created
July 11, 2020 05:53
-
-
Save TetsuFe/fbe6c91694a8c28387fa9fe02fece45f 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
class Item { | |
Item(price) { | |
this.price = price; | |
} | |
int price; | |
} | |
class Cart { | |
final items = [Item(1), Item(2)]; | |
int get totalPrice => items.fold(0, (cur, item) => cur + item.price); | |
} | |
void main() { | |
print(Cart().totalPrice); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment