Created
April 24, 2017 03:10
-
-
Save matanlurey/d4e5c1f5367e612c8797006c1f3b754a to your computer and use it in GitHub Desktop.
An example of using const in Dart
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
main() { | |
const user = const {'name': 'Joe'}; | |
// Static error: "Constant variables cannot be assigned a value". | |
user = {}; | |
// Runtime error: "Unsupported operation: Cannot modify unmodifiable Map". | |
user['name'] = 'Jill'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment