Search code examples
rubyobject

Is everything an object in ruby?


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


Solution

  • 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).