-1

I have this statement :

username.blank? ? firstname : username

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

Marek Lipka
  • 50,622
  • 7
  • 87
  • 91
barbacan
  • 632
  • 6
  • 16

1 Answers1

3

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

username.presence || firstname
Marek Lipka
  • 50,622
  • 7
  • 87
  • 91