void main() {
Student kim = new Student('kim', 15);
kim.sayName();
kim.sayAge();
new Student('lee', 20)
..sayName()
..sayAge();
}
// 학생
class Student {
String name;
int age;
Student(this.name, this.age);
void sayName() {
print('my name is ${this.name}');
}
void sayAge() {
print('my age is ${this.age}');
}
}
--------------------------------------------[result]
my name is kim
my age is 15
my name is lee
my age is 20
'Dart' 카테고리의 다른 글
[Dart] Map 고급 - entries, asMap (0) | 2021.05.28 |
---|---|
[Dart] List 고급 - forEach, map, fold, reduce (0) | 2021.05.28 |
[Dart] Class - interface (0) | 2021.05.27 |
[Dart] Class - super, this (0) | 2021.05.27 |
[Dart] Class - Static (0) | 2021.05.27 |