title: Using Ruby safe operator with greater than
body: <p>I'm trying to figure out how to use Ruby's safe operator in the following scenario:</p>
  
  <pre><code>if attribute_value &amp;&amp; attribute_value.length &gt; 255
  </code></pre>
  
  <p>The following does not work if the attribute_value is nil:</p>
  
  <pre><code>if attribute_value&amp;.length &gt; 255
  
  # NoMethodError: undefined method `&gt;' for nil:NilClass
  </code></pre>
  
  <p>I get why, but what I'd like to know is how to I get round this. The following works, but it's ugly as hell:</p>
  
  <pre><code>if attribute_value&amp;.(length &gt; 255)
  </code></pre>
  
  <p>What's the recommended way of doing this? I guess I could do the following:</p>
  
  <pre><code>if attribute_value&amp;.length.to_i &gt; 255
  </code></pre>
  
  <p>That's not so bad for this situation. Anything else?</p>