**이 페이지에서 알 수 있는 내용 このページからわかること
- Cascade Notation**
**Cascade Notation**은 변수를 작성하는 단계를 줄여, 보다 유동적으로 코드를 작성할 수 있도록 해줍니다.
**Cascade Notation**は 変数を作成する過程を減らして, より流動的にコードを作成することができるようにする。
// Cascade Notation
// late는 변수들의 값을 나중에 받아온다는 것을 의미합니다. lateは変数のバリューを後で受け取るという意味
class Dash {
late final String name;
int number; // use late
int xp;
String color;
Dash(
{required this.name,
required this.number,
required this.xp,
required this.color});
void sayHello() {
print("Hi i'm No.$number Dash");
}
}
void main() {
// normal
var character = Dash(name: "dash", number: 1, xp: 0, color: "Blue");
character.number = 2;
character.xp = 100;
character.color = 'Orange';
character.sayHello();
// Cascade Notation 1
var cascadeChar1 = Dash(name: "dash", number: 1, xp: 100, color: "Red")
..number = 3
..xp = 80
..color = "white"
..sayHello();
print(cascadeChar1);
// Cascade Notation 2
var cascadeChar2 = Dash(name: "dash", number: 1, xp: 100, color: "Red");
var cascadeChar3 = cascadeChar2
..number = 4
..xp = 80
..color = "white"
..sayHello();
print(cascadeChar3);
}