Ruby Quick Reference

Quick reference for efficient coding

View the Project on GitHub YumaYX/RubyQuickReference

main_block.rb(script)

This Ruby code checks whether the current file is being executed directly (as opposed to being required as a module in another file) and performs actions specified within the if block when true.

Execution:

if __FILE__ == $0
  # Code block to be executed only if the script is run directly

  # Add your script's main logic here
end
#=> nil

Executed with Ruby 3.3.5