DEV Community

pooyaalamdari
pooyaalamdari

Posted on

self

class C  
    def C.x # self.x, C == self, self is C
        puts "Class method: <C.x> of class C"
        puts "self: #{self}"
    end
end

C.x # self.x
Enter fullscreen mode Exit fullscreen mode
class C  
    def C.x
        puts "Class method: <C.x> of class C"
        puts "self: #{self}"
    end
end

class D < C  

end

C.x # self.x -> self is C
D.x # self.x => self is D
Enter fullscreen mode Exit fullscreen mode
class Test
  def talk

  end
end 

obj = Test.new 
obj.talk
# same as self.talk
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.