Project

General

Profile

Actions

Feature #18287

closed

Support nil value for sort in Dir.glob

Added by Strech (Sergey Fedorov) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Target version:
-
[ruby-core:105928]

Description

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0