Creating a class

Download ruby eBook

Example

You can define a new class using the class keyword.

class MyClass
end

Once defined, you can create a new instance using the .new method

somevar = MyClass.new
# => #<MyClass:0x007fe2b8aa4a18>

Stats

Contributors: 2
2016-07-20
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook