一切都是 ruby​​ 中的对象吗? [英] Is everything an object in ruby?

查看:55
本文介绍了一切都是 ruby​​ 中的对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ruby 中的所有东西都是对象吗?这包括 Fixnums 吗?

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

推荐答案

取决于您所说的一切"是什么意思.Fixnums 是,正如其他人已经证明的那样.类也是 Class 类的实例.方法、运算符和块不是,但可以由对象(Proc)包装.简单赋值不是,也不能.像 while 这样的语句也不是也不能.评论显然也属于后一组.

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

这篇关于一切都是 ruby​​ 中的对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆