[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:105960] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
From:
"Eregon (Benoit Daloze)" <noreply@...>
Date:
2021-11-06 12:19:48 UTC
List:
ruby-core #105960
Issue #18287 has been updated by Eregon (Benoit Daloze).
nobu (Nobuyoshi Nakada) wrote in #note-7:
> For instance,
> ```ruby
> Integer("010", nil) #=> 8
> ```
`base` is not a boolean argument ("do this or do not this behavior"), it doesn't apply.
BTW it seems Kernel#Integer ignores the second argument if not an Integer which I argue is a separate bug (`Integer("11", :foobar) => 11`)
The same method actually has a boolean (keyword) argument, exception, and it behaves according to the rules above:
```ruby
> Integer("x", exception: nil)
(irb):3:in `Integer': true or false is expected as exception: nil (ArgumentError)
```
That would also be fine for me, if `Dir.glob(..., sort: v)` raises if `v` if not true or false.
As an example all metprogramming methods which accept an `inherit` argument treat `nil` as `false`:
```ruby
irb(main):006:0> String.instance_methods(true).size
=> 188
irb(main):004:0> String.instance_methods(false).size
=> 129
irb(main):005:0> String.instance_methods(nil).size
=> 129
```
Maybe what I wrote in https://bugs.ruby-lang.org/issues/18287#note-3 wasn't clear?
I'm talking about Ruby code methods which take a boolean/boolean-like argument.
AFAIK all such methods (well, except `Dir.glob(..., sort:)`, which is this issue) respect the rules in that comment.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94507
* 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>