lundi 29 mai 2017

Are `if model.variable` and `unless model.variable.nil?` equivalent?

There are two if-statements to evaluate whether the object is nil.

Method: A

if object
  blahblahblah
end

Method: B

unless object.nil?
  blahblahblah
end

Are A and B identical?

Aucun commentaire:

Enregistrer un commentaire