Junior — Middle
Can you list the data types used in the Dart language?
sobes.tech AI
Answer from AI
In the Dart language, there are several basic data types:
- int — integers (e.g., 1, 42, -7)
- double — floating-point numbers (e.g., 3.14, -0.001)
- String — text strings (e.g., "Hello")
- bool — boolean values (true or false)
- List — an ordered list of elements (e.g., [1, 2, 3])
- Map — a collection of key-value pairs (e.g., {'key': 'value'})
- Set — a collection of unique elements
- dynamic — a type that allows storing values of any type, type checking occurs at runtime
- var — an implicitly typed variable, type is inferred by the compiler
Example usage:
int age = 25;
double height = 1.75;
String name = 'Ivan';
bool isStudent = true;
List<int> scores = [90, 85, 78];
Map<String, String> capitals = {'Russia': 'Moscow', 'France': 'Paris'};