vendredi 11 novembre 2016

ruby multiple or condition in a range

Is there an elegant way of achieve the following in ruby way?

x = nil #(sometimes it can be value)

y = 0 || 1 || 2 || 3 || 4

z = x || y #(if x is not nil then x else 0 || 1 || 2 || 3 || 4)

Thanks

Aucun commentaire:

Enregistrer un commentaire