Created
October 10, 2014 15:15
-
-
Save murajun1978/f1f40ad1bbf7c6bd3b37 to your computer and use it in GitHub Desktop.
__FILE__と$0の違い
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'require_file' | |
include RequireFile | |
$0 # => "current_file.rb" | |
__FILE__ # => "current_file.rb" | |
__LINE__ # => 6 | |
File.expand_path(__FILE__) # => "path/to/current_file.rb" | |
stdout_method | |
# $0 # => "current_file.rb" | |
# __FILE__ # => "path/to/require_file.rb" | |
# __LINE__ # => 5 | |
# File.expand_path(__FILE__) # => "path/to/require_file.rb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RequireFile | |
def stdout_method | |
p $0 | |
p __FILE__ | |
p __LINE__ | |
p File.expand_path(__FILE__) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment