According to pickaxe2, p516:
Module Kernel
The Kernel module is included by class Object, so its [instance] methods
are available in every Ruby object. The Kernel instance methods are
documented in class Object beginning on page 567. This section
documents the module methods. These methods are called without a
receiver and thus can be called in functional form.
I tried to model that state of affairs with this code:
module K
def K.test1
puts “test1”
end
def test2
puts “test2”
end
end
class O
include K
K.test1
test1
end
–output:–
test1
r2test.rb:16: undefined local variable or method `test1’ for O:Class
(NameError)
How come you can call Kernel methods without a receiver?