Skip to content

Instantly share code, notes, and snippets.

@JoelQ
Created January 8, 2015 16:45
Show Gist options
  • Save JoelQ/2509e9143cd12ea04e0a to your computer and use it in GitHub Desktop.
Save JoelQ/2509e9143cd12ea04e0a to your computer and use it in GitHub Desktop.
__dir__ comparison
puts "__dir__ is the same as File.expand_path(__dir__)"
puts __dir__ == File.expand_path(__dir__)
puts "__dir__ is the same as File.expand_path( File.dirname(__FILE__) )"
puts __dir__ == File.expand_path( File.dirname(__FILE__) )
puts "__dir__ is the same as File.expand_path('../', __FILE__)"
puts __dir__ == File.expand_path("../", __FILE__)
# Script Output:
#
# __dir__ is the same as File.expand_path(__dir__)
# true
# __dir__ is the same as File.expand_path( File.dirname(__FILE__) )
# true
# __dir__ is the same as File.expand_path('../', __FILE__)
# true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment