Why is the power!
method in Ruby's Fixnum
class named with an exclamation mark? By convention, methods that have a name ending in an ! are potentially dangerous (for example, they may modify the instance in some way).
I can appreciate the difference between gsub
and gsub!
in String
, but what's up with power!
? It doesn't seem to modify the Fixnum
instance or perform any other "dangerous" actions; it just returns the result.
It's just an inconsistency in the API. Nothing to worry about, move along :)
The
!
is just a convention for destructive methods, not a rule.