One of the little things that makes ruby so different is the fact that you can use punctuation in the name of your methods. I could really well be wrong on this, but I think ruby is the only language that allows a programmer to name his method logged? for example. Oh well, I should play it more safe. Let’s say that ruby is the only language I know that allow this.
It’s great because just by looking at the question mark, you know what the method is all about and that it will (should) return yes or no. The other punctuation character you can use is the exclamation (!). It is generally used to announce some kind of destructive action or something that is unusual. The “!” sign is used a lot in Rails ActiveRecord methods. For example, you can call both myObject.save and myObject.save!
What is the difference? myObject.save! will raise an exception if something went wrong in the process of saving the object back to the database while myObject.save will remain silent.
What’s your take on using punctuation in method names? Is it a useful feature or just flash in the pan?