javascript - Empty set in type script -
i have theoretical question. there way design type in typescript denotes empty set? tried define 1 using union, disjoint union, intersection , more...
yes, although think usefulness of such type depends lot on style of programming. define emptyset this:
interface iset { intersection: (s: iset) => iset; union: (s: iset) => iset; } class emptyset implements iset { intersection(s: iset) { return this; } union(s: iset) { return s; } } class nonemptyset implements iset { ... } iset generic contract of set, emptyset concrete type implements contract. can more things set union , intersection, example.
Comments
Post a Comment