Ruby Keyword: begin - rking/pry-docmore GitHub Wiki
Like Perl and Awk before that, defines a block to be run before the others:
p 3
BEGIN { p 1 }
p 4
BEGIN { p 2 }
# …prints these out as 1, 2, 3, 4
This works because the whole file gets parsed at the beginning (even though 'class' and 'def' lines are not executed early), so the interpreter can reorder these statements.
See also: END
(Not to be confused with lower-case begin)