Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Kernel#global_variables

global_variables → array

Returns an array of the names of global variables. This includes special regexp global variables such as $~ and $+, but does not include the numbered regexp global variables ($1, $2, etc.).

Example
global_variables.grep /std/   #=> [:$stdin, :$stdout, :$stderr]
See also #gets #gsub #gem_original_require #Hash also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1