Ruby中不是对象的“事物"的示例 [英] Examples of 'Things' that are not Objects in Ruby

查看:45
本文介绍了Ruby中不是对象的“事物"的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一切都是对象"是我了解Ruby的第一件事,但是在Peter Cooper的 Ruby入门:从新手到专业中,提到了< 几乎 Ruby中的所有东西都是对象".

"Everything is an object" was one of the first things I learned about Ruby, but in Peter Cooper's Beginning Ruby: From Novice to Professional, it is mentioned that "almost everything in Ruby is an object".

您能给我一些不是Ruby中对象的事物的示例吗?

Can you give me some examples of things that are not objects in Ruby?

推荐答案

跳到我头上最明显的一个是块.通过使用参数列表中的&block参数形式或使用lambdaprocProc.new或(在Ruby 1.9中)"stabby lambda",可以轻松地将块修改为Proc对象.句法.但就其本身而言,它们不是对象.

The most obvious one that jumps into my head would be blocks. Blocks can be easily reified to a Proc object, either by using the &block parameter form in a parameter list or by using lambda, proc, Proc.new or (in Ruby 1.9) the "stabby lambda" syntax. But on its own, they aren't objects.

另一个例子是运算符.

这篇关于Ruby中不是对象的“事物"的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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