Ruby Language Reference

BEGIN Statement

Example

The BEGIN is not to be confused with begin.

BEGIN {
  p 'The code to run before the program is run'
}

p 'hi'

This prints:

The code to run before the program is run
hi


Sharing is Caring