Ruby Language Loading Source Files Require files to be loaded only once

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The Kernel#require method will load files only once (several calls to require will result in the code in that file being evaluated only once). It will search your ruby $LOAD_PATH to find the required file if the parameter is not an absolute path. Extensions like .rb, .so, .o or .dll are optional. Relative paths will be resolved to the current working directory of the process.

require 'awesome_print'

The Kernel#require_relative allows you to load files relative to the file in which require_relative is called.

# will search in directory myproj relative to current source file.
#
require_relative 'myproj/version'  


Got any Ruby Language Question?