Why is __FILE__ uppercase and __dir__ lowercase?

后端 未结 2 754
谎友^
谎友^ 2020-12-05 01:19

In Ruby 2.0.0-p0, the __dir__ variable was introduced for easy access to the directory of the file currently being executed.

Why is __dir__

2条回答
  •  不知归路
    2020-12-05 02:11

    I think that is because __FILE__ is a parse-time constant whereas __dir__ is a function and returns File.dirname(File.realpath(__FILE__))

    For more details, see This discussion

提交回复
热议问题