Data Types in Dart
What are Data Types?
Dart supports different data types for different tasks. Like in life, we use words to communicate and numbers to calculate.
Dart allows us to use numbers for mathematical operations:
main.dart
123void main() { print(22+33); }
In Dart, we can join strings:
main.dart
123void main() { print("Name " + "Alex"); }
We can use the bool
data type to print whether a statement is true
or false
:
main.dart
1234void main() { // 2 > 1 ? print(true); }
In the future, we will learn to work with all types of data, and in the following chapters we will consider the simplest of them.
What Are the Differences Between Data Types?
For example, we can perform mathematical operations between int
and double
because both are numbers.
However, we cannot add a String
to an int
or double
because a String
is simply a sequence of characters, which does not support mathematical operations.
main.dart
123void main() { print("String example " + 44); }
Tack för dina kommentarer!
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 4.55
Data Types in Dart
Svep för att visa menyn
What are Data Types?
Dart supports different data types for different tasks. Like in life, we use words to communicate and numbers to calculate.
Dart allows us to use numbers for mathematical operations:
main.dart
123void main() { print(22+33); }
In Dart, we can join strings:
main.dart
123void main() { print("Name " + "Alex"); }
We can use the bool
data type to print whether a statement is true
or false
:
main.dart
1234void main() { // 2 > 1 ? print(true); }
In the future, we will learn to work with all types of data, and in the following chapters we will consider the simplest of them.
What Are the Differences Between Data Types?
For example, we can perform mathematical operations between int
and double
because both are numbers.
However, we cannot add a String
to an int
or double
because a String
is simply a sequence of characters, which does not support mathematical operations.
main.dart
123void main() { print("String example " + 44); }
Tack för dina kommentarer!