Home Ruby 记一下这些年不常用的内容include,extend,block,proc,lambda,self<<
Post
Cancel

Ruby 记一下这些年不常用的内容include,extend,block,proc,lambda,self<<

include:  进来的都是 instance method

extend:  过来的都是 class method

定义class method的方法:  def self.xx   def ClassName.xx  

class SomeClass
   class << self
      def xx   # 这也是个class method
      end 
   end
end

require: 只加载一次

load: 可以加载多次

This post is licensed under CC BY 4.0 by the author.