I was wondering why puts, which I use casually, can be used, so I looked it up.
** In conclusion, one Kernel module was biting. ** **
Methods provided by the Kernel module
puts
p
print
require
gets
It seems that the above methods are defined in the Kernel module.
Classes such as String, Numeric, Array, and Hash all seem to inherit from the Object class.
Confirm parent class
$ rails c
>> String.superclass
=> Object
>> Numeric.superclass
=> Object
>> Array.superclass
=> Object
>> Hash.superclass
=> Object
Originally, ** the Object class (superclass is BasicObject), which is almost all parent classes, includes the Kernel module **, so It seems that you can use any class by default without thinking about the puts method.
Below is a list of specific methods defined in the Kernel module.
Recommended Posts