Project

General

Profile

Actions

Feature #18332

open

a ? b

Added by dorianmariefr (Dorian Marié) over 2 years ago. Updated over 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:106041]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0