Is everything an object in ruby?

前端 未结 6 1313
迷失自我
迷失自我 2020-12-10 12:03

Is everything in ruby an object? Does this include Fixnums?

6条回答
  •  心在旅途
    2020-12-10 12:37

    Depends on what you mean by "everything". Fixnums are, as the others have demonstrated. Classes also are, as instances of class Class. Methods, operators and blocks aren't, but can be wrapped by objects (Proc). Simple assignment is not, and can't. Statements like while also aren't and can't. Comments obviously also fall in the latter group.

    Most things that actually matter, i.e. that you would wish to manipulate, are objects (or can be wrapped in objects).

提交回复
热议问题