Is Class declaration an eyewash in ruby? Is everything really object oriented?

前端 未结 2 1510
广开言路
广开言路 2021-01-22 13:28
class Person
  def name
   puts \"Dave\"
  end
end

puts Person.object_id

There are only two ways of accessing methods :

1) Someclass.method in

2条回答
  •  终归单人心
    2021-01-22 14:09

    Yes, Ruby classes are objects:

    >> String.is_a? Object
    => true
    >> String.methods.count
    => 131
    >> Fixnum.methods.count
    => 128
    

提交回复
热议问题