So I had this situation where I needed to delete an object from the database, if it existed. This is what I wrote:
Ruby Option 1
obj = get_object(1) obj.destroy if obj
And as I wrote this, it seemed a bit awkward to me. We always said Ruby had a really elegant syntax, but I guess I've come to the place where I find it a little grating. The thing about this example is the asymmetry of it. Conceptually I feel like the if check goes with the assignment, but it's separated from it in a strange way.