π₯ Collection
λ°μ΄ν°λ€μ λͺ¨μμ κ°μ§κ³ μλ μλ£κ΅¬μ‘°
π§βπ³ Generic
Collection μ΄ κ°μ§κ³ μλ λ°μ΄ν°λ€μ λ°μ΄ν° νμ μ μ§μ
μ½λμ μμ μ± ν보 λ° μ½λμ μ¬μ¬μ©μ± μ
λ€λ₯Έ μΈμ΄μμμ λ°°μ΄ == νλ¬ν°μμ 리μ€νΈ
fixed-length list
=> 리μ€νΈ λ΄μ λ°μ΄ν° κ°μκ° μ§μ ν κ°μλ§νΌ μ¬ μ μλ€
growable list
=> 리μ€νΈ λ΄μ λ°μ΄ν° κ°μ μ ν μμ
void main(){
var number1 = new List();
// number λ List νμ
// 리μ€νΈ λ΄ λ€μν νμ
μ λ°μ΄ν°λ€μ΄ λ€μ΄μ¬ μ μμ
List number2 = new List();
number2.add(2);
number2.add('test');
number2.add(7.4);
print(number);
}
dynamic
-> μ¬λ¬ νμ
μ΄ μ¬ μ μλ€!void main(){
List<dynamic> number = new List();
List<int> number2 = new List();
List<String> number2 = new List();
}
class Circle {}
class Square {}
class SquareSlot {
insert(Square sqareSlot) {}
}
class CircleSlot {
insert(Circle circleSlot) {}
}
void main() {
var circleSlot = new CircleSlot();
circleSlot.insert(new Circle());
var squareSlot = new SquareSlot();
squareSlot.insert(new Circle());
}
class Circle {}
class Square {}
class SquareSlot {
insert(Square sqareSlot) {}
}
class CircleSlot {
insert(Circle circleSlot) {}
}
class Slot<T> {
insert(T shaape) {}
}
void main() {
var circleSlot2 = new Slot<Circle>();
circleSlot2.insert(new Circle());
var squareSlot2 = new Slot<Square>();
squareSlot2.insert(new Square());
}