Created
September 22, 2021 06:26
-
-
Save suragch/a4a52e98bd46512b79c55783e3e4cf90 to your computer and use it in GitHub Desktop.
Homework from September 22
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() { | |
// types | |
int a = 1; | |
double b = 2.1; | |
String c = 'hello'; | |
Object d = 2.1; | |
d = 1; | |
d = 'hello'; | |
dynamic e = 1; | |
e = 'hello'; | |
// is | |
print(a is int); // true | |
print(b is String); // false | |
// converting types | |
var myInt = 8; | |
var myDouble = myInt.toDouble(); | |
print(myDouble is double); // true | |
// mixing types | |
int x = 2; | |
double y = 4.9; | |
var z = x + y; | |
print(z is double); // true | |
// dividing int gives double | |
const answer = 4 / 4; | |
print(answer is double); // true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment