Is there any way to use typescript in my code Collections. HashTable?
•
Java
I saw the implementation of "hashtable" in the code of typescript compiler (in the file Src / compiler / core / hashtable. TS)
Do you know how to use it directly in my typescript project?
Solution
You can implement a very simple hash table by defining an interface, where the key is a string
class Person { name: string; } interface HashTable<T> { [key: string]: T; } var persons: HashTable<Person> = {}; persons["bob"] = new Person(); var bob = persons["bob"];
It can only type strings or numbers
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码