What is the difference between a type and a class? They look the same.
Sorry to ask something so elementary.
What is the difference between a type and a class? They look the same.
Sorry to ask something so elementary.
That’s pretty much how it works since everything is an Object. "foo"
's type is String
since it is an instance of the String
class. The type of a variable/value would be the class it is an instance of, or a union of all the classes it could be an instance of.
The main difference is a type is not limited to a class
. But could also be structs, modules, enums, array of a type, etc.
I understand. Thank you!