> I think that highlights that using #empty? to detect "unset" is just
> the wrong approach. Any variable is nil - unless assigned otherwise.
> So it's much more easier to rely on nil as the unassigned state.

Well, sure.  But if you are capturing the state from somewhere else then you don't get to make that assumption.  For example, if you are entering it on the command line with `gets()` (the simplest example), if the user presses return you will get an empty string, not nil.

I can certainly say

    entered_value = nil if entered_value.empty?

... and then pass it to your very elegant class -- but this is back to the same problem we had before, except that the code is now in two different places.





Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>