Created
August 1, 2019 21:12
-
-
Save mohit242/168d70b7daaa94f9dcb6dad007ed292e to your computer and use it in GitHub Desktop.
FirstProgram
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() { | |
String name = "Bob"; | |
var name_ = "Bob"; | |
// Automatically infers type. name contains refernee to String object with value "Bob" | |
// name = 22; Cannot assign value of different type | |
// Note: Dart is strongly typed | |
dynamic planet = "Earth"; | |
planet = 33; | |
// Default value of every variable is null | |
int lineCount; | |
print(lineCount); | |
assert(lineCount == null); | |
// final variable can only be set only once; a const variable is a compile-time constant | |
final x = 'Bob'; | |
const bar = 100000; | |
// const can also be used to create const values | |
var foo = const []; | |
foo = ["Hello"]; | |
print(foo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment