class / initialize
Defines your own type (class).
Syntax
class Name
def initialize(p)
@field = p
end
endDescription
Classes are defined with class. initialize is the constructor method (runs when an object is created). @area is an instance variable (belongs to the object).
Example
Loading editor…
Expected output
Tabby: meow
When to use?
Object-oriented design.