Ruby method, Proc, and block confusion

前端 未结 3 1200
春和景丽
春和景丽 2021-02-07 01:04

I have a couple questions about Ruby\'s methods, procedures, and blocks that strike me as rather odd. They\'re not so much about syntax or function as the logic behind the deci

3条回答
  •  梦如初夏
    2021-02-07 01:27

    To some extent at least, methods are objects:

    class ABC
      def some_method
      end
    end
    ABC.instance_method(:some_method) #=> #
    

    Further to that, there is a built-in class: Method, as documented here.

    See also this: http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls

    Haphazardly , it does rather seem to bear out the everything-is-an-object thing. In this particular case, it just appears to take a little more digging to see.

    (I really must make an effort to understand this better: I'm starting to think it's fundamental to getting a deeper understanding.)

提交回复
热议问题