Skip to content

Instantly share code, notes, and snippets.

@danim1130
Created September 8, 2020 01:05
Show Gist options
  • Save danim1130/ed3ff06eab7c266be72c9335b18ff6dc to your computer and use it in GitHub Desktop.
Save danim1130/ed3ff06eab7c266be72c9335b18ff6dc to your computer and use it in GitHub Desktop.
Dart - Primitive types
void main() {
//Különbség int és double között
int firstInt = 5;
double firstDouble = 5;
num firstNum = 5;
print("Testing 5");
print(firstInt.runtimeType);
print(firstDouble.runtimeType);
print(firstNum.runtimeType);
//int secondInt = 5.0; !ERROR!
double secondDouble = 5.0;
num secondNum = 5.0;
print("Testing 5.0");
print(secondDouble.runtimeType);
print(secondNum.runtimeType);
double thirdDouble = 5.1;
num thirdNum = 5.1;
print("Testing 5.1");
print(thirdDouble.runtimeType);
print(thirdNum.runtimeType);
//firstInt = firstDouble; !ERROR!
//firstDouble = firstInt; !ERROR!
firstInt = firstDouble.toInt();
firstDouble = firstInt.toDouble();
firstNum = firstInt;
firstNum = firstDouble;
//Int hossza
print("Testing int length");
print(1 << 31);
print(1 << 32);
bool testBool = true;
//Null
int nullInt = null;
print("Null értékei");
print(nullInt.runtimeType);
print(nullInt.hashCode);
print(nullInt.toString());
//print(a.abs()); !ERROR!
//Dynamic típus
dynamic testDynamic;
testDynamic = 5;
print(testDynamic.runtimeType);
testDynamic = "Hello Dynamic!";
print(testDynamic.runtimeType);
//testDynamic.gcd(3); !ERROR!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment