Domanda

I have this statement :

username.blank? ? firstname : username

There is a shortcut or a way to avoid repeating 'username' ?

È stato utile?

Soluzione

As it seems you're using ActiveSupport, there is simple way to do this:

username.presence || firstname
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top