[#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:106084] [Ruby master Feature#18273] Class#subclasses
From:
"mame (Yusuke Endoh)" <noreply@...>
Date:
2021-11-16 09:07:40 UTC
List:
ruby-core #106084
Issue #18273 has been updated by mame (Yusuke Endoh).
mame (Yusuke Endoh) wrote in #note-8:
> sawa (Tsuyoshi Sawada) wrote in #note-7:
> > Was the method name `Class#superclass` appropriate?
>
> I think we don't say "C is a superclass of E" in the same situation, but I'm unsure.
Ah, I misunderstood. I have no idea whether an alias `Class#parent` is needed.
----------------------------------------
Feature #18273: Class#subclasses
https://bugs.ruby-lang.org/issues/18273#change-94673
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
Ref: https://github.com/rails/rails/pull/43481
Something we forgot to mention in [Feature #14394], is either a parameter or another method to only get direct descendants.
Active Support has been offering `Class.subclasses` as:
```ruby
def subclasses
descendants.select { |descendant| descendant.superclass == self }
end
```
It seems a bit silly to grab all descendants and then restrict the list when `Class#descendants` had to do some recursion to get them all in the first place.
### Proposal
We could either implement `Class#subclasses` directly, or accept a parameter in `Class#descendants`, e.g. `descendants(immediate = false)`.
cc @eregon
--
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>