You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One solution (and in fact the only one in languages that don't support generics) is to go ahead and create *special* classes just for these constraints. E.g. a quick and dirty number queue:
41
41
42
42
```ts
43
-
classQueueNumber {
44
-
private data = [];
45
-
push = (item:number) =>this.data.push(item);
46
-
pop = ():number=>this.data.shift();
43
+
classQueueNumberextendsQueue {
44
+
push(item:number) { super.push(item); }
45
+
pop():number { returnthis.data.shift(); }
47
46
}
48
47
49
48
const queue =newQueueNumber();
@@ -59,8 +58,8 @@ Of course this can quickly become painful e.g. if you want a string queue you ha
59
58
/** A class definition with a generic parameter */
0 commit comments