title: How do write conditional statement in a single line? rails
body: <p>I am trying to say this </p>
  
  <pre><code>self.preferred_amount * object.each{|li|li.variant}.collect{|li|li.weight}
  </code></pre>
  
  <p>The only problem is that certain weights equal nil.</p>
  
  <p>Being that the case, I would like to add that if they do equal nil, make them equal 0.</p>
  
  <p>Is there any way to incorporate this logic in the same line?</p>
  
  <p>Or is there a way I can make this statement even more refactored than it is?</p>