bbatsov/ruby-style-guide — Issue #79: method names with ! should return self
Author: SirLenz0rlot
Created: 2012-02-29 09:44:03+00:00
State: open

I had a discussion with someone this week about a method with a '!'-postfix, lets say its called order!

When I call foo.order! I could not think of a use case where its return value is not the ordered foo.

This convention is useful in method chaining (though you should not chain always everything you can).
e.g.
foo.order!.validate!

What do you think about this?

Maybe it would be good to add conventions about '?' and '!' postfixes in method names anyways?
even thought they are quite basic?