Currently, as far as I know,
if' andunless’ merely check if an object
is of either types NilClass or FalseClass. This seems to contradict the
duck-typing paradigm. I propose that we implement a method Object#to_b
that is called by
if' andunless’. It should return a boolean value.
That way, a developer can decide whether or not an object should
evaluate to true or false.
def open?; end
def closed?; end
def to_b; open?; end
connection = Connection.new(…)
One problem I see with this proposal is that it seems like a lot of
people check if a variable has been set by writing
if var ...'. This change would require that people wroteunless var.nil?’, which I
personally find more correct as well.