class Person
def name
puts \"Dave\"
end
end
puts Person.object_id
There are only two ways of accessing methods :
1) Someclass.method in
Yes, classes in Ruby are instances of class Class. In fact, you can create the same class just with:
Person = Class.new do
define_method :name do
puts 'Dave'
end
end
Then, you can just type Person.new.name and it will work exactly as your class.
Checking that Person is an instance of class Class is as easy as typing in your repl Person.class and you get Class in return.