Files
wren/doc/site/core/class.markdown
T
Bob Nystrom 8436ead62e feat: add Class.supertype primitive and documentation for retrieving superclass
Implement a new `supertype` property on Class objects that returns the superclass of a given class. The primitive `class_supertype` checks if the class has a superclass (returning null for Object) and returns the superclass object. Includes documentation in the class reference and a test file verifying behavior for explicit superclasses, implicit Object inheritance, and Object's null supertype.
2015-03-14 16:48:45 +00:00

493 B

^title Class Class ^category core

name

The name of the class.

supertype

The superclass of this class.

:::dart
class Crustacean {}
class Crab is Crustacean {}

IO.print(Crab.supertype)        // "Crustacean"

A class with no explicit superclass implicitly inherits Object:

:::dart
IO.print(Crustacean.supertype)  // "Object"

Object forms the root of the class hierarchy and has no supertype:

:::dart
IO.print(Object.supertype)  // "null"