On this page
End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
Kernel
RubyGems adds the gem method to allow activation of specific gem versions and overrides the require method on Kernel to make gems appear as if they live on the $LOAD_PATH. See the documentation of these methods for further detail.
The Kernel module is included by class Object, so its methods are available in every Ruby object.
The Kernel instance methods are documented in class Object while the module methods are documented here. These methods are called without a receiver and thus can be called in functional form:
sprintf "%.1f", 1.234 #=> "1.2"
Class methods 2
Instance methods 83
Ruby version changes 6
-
3.0
-
Kernel#clonewhen called with thefreeze: falsekeyword will call initialize_clone with thefreeze: falsekeyword. [Bug #14266] -
Kernel#clonewhen called with thefreeze: truekeyword will call initialize_clone with thefreeze: truekeyword, and will return a frozen copy even if the receiver is unfrozen. [Feature #16175] -
Kernel#evalwhen called with two arguments will use “(eval)” for__FILE__and 1 for__LINE__in the evaluated code. [Bug #4352] -
Kernel#lambdanow warns if called without a literal block. [Feature #15973] -
Kernel.sleepinvokes the scheduler hook kernel_sleep(…) in a non-blocking execution context. [Feature #16786] -
Random::DEFAULTis deprecated since its value is now confusing and it is no longer global, useKernel.rand/Random.randdirectly, or create aRandominstance withRandom.newinstead. [Feature #17351]
-