[#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:106044] [Ruby master Feature#18332] a ? b
From:
"zverok (Victor Shepelev)" <noreply@...>
Date:
2021-11-13 20:36:39 UTC
List:
ruby-core #106044
Issue #18332 has been updated by zverok (Victor Shepelev).
Well, obviously that's a matter of personal taste, but for a one-branch `if` the postfix form seems to read naturally ("this item will have class "font-bold" if it is root).
So it might be that `cond ? result` reads better for you because you invented it starting to think from `cond ? result : else` (which, should we say, is quite esoteric on itself, we just got used to it)
----------------------------------------
Feature #18332: a ? b
https://bugs.ruby-lang.org/issues/18332#change-94633
* Author: dorianmariefr (Dorian Mari辿)
* Status: Open
* Priority: Normal
----------------------------------------
It would be a shortcut for `a ? b : nil`:
e.g.
```
"#{current_path == "/" ? "font-bold"}"
"#{user.admin? ? "text-red-600"}"
```
Doing `a && b` returns `false` which converted to a string gives `"false"`.
When `nil` converts to a string it gives `""`.
I would use it mostly in string interpolations.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>