[#115884] Windows Ruby 3.2.2: Non-English character added to Windows Registry String Value — Jay Mav via ruby-core <ruby-core@...>
Hello,
3 messages
2023/12/24
[ruby-core:115704] [Ruby master Misc#20056] Dir#chdir inconsistency with Dir.chdir
From:
"zverok (Victor Shepelev) via ruby-core" <ruby-core@...>
Date:
2023-12-11 22:14:06 UTC
List:
ruby-core #115704
Issue #20056 has been updated by zverok (Victor Shepelev).
> That's more or less the same diff I came up with before I determined we need more refactoring so that `Dir#chdir` never yields an argument to the block.
I provided the diff to solve return value problem for the **block form**. Which is not a _big_ problem, but still might be confusing:
```ruby
Dir.chdir('doc') do
# ...some more logic or calling other modules
# ...which might do something like...
Dir['*.md'].map { File.read(_1) }.join("\n\n")
end #=> what was calculated in the block
Dir.new('doc').chdir do
Dir['*.md'].map { File.read(_1) }.join("\n\n")
end #=> nil
```
This is simply fixed by `return`ing what the called method have returned, right? Whatever the implementation is chosen.
----------------------------------------
Misc #20056: Dir#chdir inconsistency with Dir.chdir
https://bugs.ruby-lang.org/issues/20056#change-105635
* Author: zverok (Victor Shepelev)
* Status: Open
* Priority: Normal
* Assignee: jeremyevans0 (Jeremy Evans)
----------------------------------------
I am not sure it is important; I just wanted to understand if this is intentional or accidental.
1. There is no block form for `Dir#chdir`, unlike `Dir.chdir` (the form that will return to the previous directory when the block is finished)
2. `Dir.chdir` returns `0`, while `Dir#chdir` returns `nil` (both seem to be not representing any particular internal value, just a hardcoded return value).
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/