Ruby methods without class?

Hello everybody! I was wondering how methods in Ruby work that don't call syntax ClassName.method_name. Someone from my head - puts, print, gets, chomp. These methods can be called without using the point operator. Why is this? Where are they from? And how can I see a complete list of such methods?
+5
source share
2 answers

All methods in Kernelwill be available for all objects of the class Objector any class derived from Object. You can use Kernel.instance_methodsto list them.

+8
source

They come from a module Kernelthat automatically turns on for each class. These

irb(main):001:0> class Foo
irb(main):002:1> end
=> nil
irb(main):003:0> Foo.included_modules
=> [Kernel]
+1
source

All Articles