presence()
Instance Public methods
Returns the receiver if it's present otherwise returns
nil
. object.presence
is equivalent to
object.present? ? object : nil
For example, something like
state = params[:state] if params[:state].present? country = params[:country] if params[:country].present? region = state || country || 'US'
becomes
region = params[:state].presence || params[:country].presence || 'US'
@return [Object]
Please login to continue.