Skip to content

Instantly share code, notes, and snippets.

@suragch
Created September 22, 2021 06:26
Show Gist options
  • Save suragch/a4a52e98bd46512b79c55783e3e4cf90 to your computer and use it in GitHub Desktop.
Save suragch/a4a52e98bd46512b79c55783e3e4cf90 to your computer and use it in GitHub Desktop.
Homework from September 22
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