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
参数形式或使用lambda
,proc
,Proc.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.
另一个例子是运算符.