Heads up: This description was created by AI and might not be 100% accurate.
dir.rb
This Ruby code snippet demonstrates how to use the __dir__
method to get the current working directory of the program.
puts __dir__
This will output the current working directory of the program.
Note: The __dir__
method is a built-in method in Ruby that returns the path of the current working directory.
Additional Note
__dir__
is a built-in method in Ruby that returns the absolute path of the directory containing the source file in which it is called. It provides a convenient way to reference the current script’s directory.
Ruby code snippet
__dir__
#=> "."
Executed with Ruby 3.4.4
.