Issue #13126 has been updated by Artem Shein.


Nobuyoshi Nakada wrote:
> When the third argument is not given, `__FILE__` in `eval` is `"(eval)"`.
> Do you mean that `__dir__` should be `"."`?

No, I mean that documentation is saying:
"The return value equals to File.dirname(File.realpath(__FILE__))." here: http://ruby-doc.org/core-2.3.0/Kernel.html#method-i-__dir__

I've replaced the "File.dirname(File.realpath(__FILE__))" in my source code with "__dir__" and got different result. I don't care about the exact value, but I expect it to be the same.



----------------------------------------
Bug #13126: __dir__ in eval returns nil
https://bugs.ruby-lang.org/issues/13126#change-62485

* Author: Artem Shein
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
~~~
$ ruby -e 'eval "p File.dirname(__FILE__); p __dir__"'
"."
nil
~~~




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>