A Class represents the type of values and objects. They are created with the class keyword. See Classes section in the Agate language.

Methods

hash

Get the hash for the class. The hash is computed thanks to the name of the class.

class Cancoillote { }

IO.println(Cancoillote.hash == "Cancoillote".hash) #> true
IO.println(Object.hash == "Object".hash)           #> true

name

Get the name of the class.

class Cancoillote { }

IO.println(Cancoillote.name) #> Cancoillote
IO.println(Object.name)      #> Object

See also: to_s

supertype

Get the superclass of the class. A class with no explicit superclass inherits from Object. Object is the root of the class hierarchy and has no superclass.

class Cheese { }
class Cancoillote is Cheese { }

IO.println(Cancoillote.supertype) #> Cheese
IO.println(Cheese.supertype)      #> Object
IO.println(Object.supertype)      #> nil

to_s

Return a String representing the name of the class.

class Cancoillote { }

IO.println(Cancoillote.name) #> Cancoillote
IO.println(Object.name)      #> Object

See also: name