From: "jeremyevans0 (Jeremy Evans)" Date: 2021-11-05T19:06:59+00:00 Subject: [ruby-core:105951] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Issue #18287 has been updated by jeremyevans0 (Jeremy Evans). Eregon (Benoit Daloze) wrote in #note-5: > @jeremyevans0 Do you know any other core method with this behavior? I don't, but I didn't do an audit. > And BTW I think the code is better without the `== false` (and with `if opts[:something]`) That changes the behavior if the option is not passed, which is very much not what is desired in cases where `== false` is used. You could switch to `opts.fetch(:something, true)`, and there are cases where I use that approach instead. > but it doesn't matter, this is core methods, not general Ruby code which has different conventions. Fair enough. I don't object to changing the behavior, I just think the current behavior is reasonable. ---------------------------------------- Feature #18287: Support nil value for sort in Dir.glob https://bugs.ruby-lang.org/issues/18287#change-94498 * Author: Strech (Sergey Fedorov) * Status: Open * Priority: Normal ---------------------------------------- Good day, everyone. I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`. I find this behaviour a bit surprising, here is an example: ``` irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true) => ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"] irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false) => ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"] irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil) => ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"] ``` As you can see ��� `sort: nil` produces the same results as `sort: true` which is confusing Github link: https://github.com/ruby/ruby/pull/5079 Ruby spec link: https://github.com/ruby/spec/pull/894 -- https://bugs.ruby-lang.org/ Unsubscribe: