ruby main idiom

Because I keep forgetting, it’s


if $0 == __FILE__
  puts "main"
end

where __FILE__ contains the name of the file that the currently executing code is located in and $0 is the name of the currently executing program.

Comments are closed.