Often I want to write something that returns “Yes” if true, “No” if false, or “NA” (or any other string really) if nil. Currently I do this:
@contact.boolean ? 'Yes' : (@contact.boolean.nil? ? "NA" : "No")
Is this the shortest way to write this?
Here’s one idea:
So, of course, you would do
{true => "Yes", false => "No", nil => "N/A"}[value]