From: "joelb (Joel Blum)" Date: 2021-12-28T14:48:29+00:00 Subject: [ruby-core:106866] [Ruby master Feature#18332] a ? b Issue #18332 has been updated by joelb (Joel Blum). If we adopt this syntax it might be worthwhile to consider JS new colaescing operator which does the same thing, maybe it's better to keep the syntax similar to JS. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator. So basically just a ?? b ---------------------------------------- Feature #18332: a ? b https://bugs.ruby-lang.org/issues/18332#change-95677 * 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: