The code in a block labeled with the keyword BEGIN is run automatically when a Ruby program is loaded : BEGIN END « Statement « Ruby






The code in a block labeled with the keyword BEGIN is run automatically when a Ruby program is loaded


BEGIN {puts "Hi "}

puts "there "

END {puts "sweetie."}

 








Related examples in the same category

1.Execution Before or After a Program
2.The code in a block labeled END is automatically run when the program finishes.