一切都是 ruby 中的对象吗? [英] Is everything an object in ruby?
问题描述
ruby 中的所有东西都是对象吗?这包括 Fixnum
s 吗?
Is everything in ruby an object? Does this include Fixnum
s?
推荐答案
取决于您所说的一切"是什么意思.Fixnum
s 是,正如其他人已经证明的那样.类也是 Class
类的实例.方法、运算符和块不是,但可以由对象(Proc
)包装.简单赋值不是,也不能.像 while
这样的语句也不是也不能.评论显然也属于后一组.
Depends on what you mean by "everything". Fixnum
s 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).
这篇关于一切都是 ruby 中的对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!