Mixin

송민경's avatar
Apr 05, 2024
Mixin
Contents

Mixin

  • 컴퍼지션 할 필요가 없음
  • new 가능함
  • has의 관계를 가질 수 있음 → with = has
mixin class Engine { int power = 1000; } class Car with Engine {} void main() { Car c = Car(); print(c.power); }
notion image
mixin class Wheel { String name = "바퀴"; } mixin class Engine { int power = 1000; } class Car with Engine, Wheel {} void main() { Car c = Car(); print(c.power); print(c.name); }
notion image
Share article
RSSPowered by inblog