So the following code snippet
Set mySet = {1,2,3};
is an instance of type Set which is permissible, however what would the class of the set literal be. I have tried to search for this, however I have found no answer in the dart documentation.
A literal exists only in your source code. Asking for its "class" doesn't make a lot of sense.
Using a Set
, Map
, or List
literal is just syntactic sugar for invoking a corresponding constructor. The Set
factory constructor constructs a LinkedHashSet
.
However, you'll see that LinkedHashSet
is also abstract. Its factory constructor returns an instance of a private, internal class. You can see its typename via print(Set().runtimeType)
; the actual type might be different for different platforms and is unlikely to be useful to you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.