Examples of 'Things' that are not Objects in Ruby

前端 未结 4 989
离开以前
离开以前 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

    After splitting the script into meaningful tokens by the lexer, everything is an object. Including classes. Even literal constants like 1 are objects. Some objects may have a syntax that is not purely OO (i.e. syntactic sugar) but that's mostly for easy manipulation more than anything. Blocks are not strictly objects though (but can as someone said be converted into one).

提交回复
热议问题