Examples of 'Things' that are not Objects in Ruby

前端 未结 4 991
离开以前
离开以前 2021-02-05 08:23

\"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 \

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 09:13

    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.

    Another example are operators.

提交回复
热议问题