[#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:106121] [Ruby master Feature#12495] Make "private" return the arguments again, for chaining
From:
"matz (Yukihiro Matsumoto)" <noreply@...>
Date:
2021-11-18 06:47:57 UTC
List:
ruby-core #106121
Issue #12495 has been updated by matz (Yukihiro Matsumoto). Sounds OK. Accepted. The side effect should be trivial. Matz. ---------------------------------------- Feature #12495: Make "private" return the arguments again, for chaining https://bugs.ruby-lang.org/issues/12495#change-94718 * Author: herwinw (Herwin Quarantainenet) * Status: Open * Priority: Normal ---------------------------------------- Ruby 2.1 introduced the feature to make `def foo` return the symbol, so this could be used by things like `private` (see #3753): ```ruby private def foo() end ``` You could use the same method to create your own decorators (name borrowed from Python) ```ruby def cached(name) # Rewrite method to include a cache return name end private cached def foo() end ``` Currently, this would work but `cached private def foo()` would not. `private` (and all other modifier functions) return the class on which it was called. It would be nice to exterminate those order-dependencies. The attached patch fixes this. It includes three modes: No arguments: return `nil`: ```ruby private def foo() end ``` One argument: return the symbol. The would be the most common use case for this example. ```ruby private def foo() end private :bar ``` Multiple arguments: return an array of the arguments: ```ruby private :foo, :bar ``` ---Files-------------------------------- ruby_return_symbols_in_private.diff (1.19 KB) -- 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>