X
Xagyg
Xagyg said:In Ruby, a method that modifies the instance using it is suffixed with
a '!'.
E.g. someString.reverse() returns a String with a reversed result,
however, someString.reverse! reverses the result of someString.
Does anyone have/use/know of a method-naming convention in Java to
distinguish between methods that modify the instance and methods that
don't?
Feel free to suggest one if you like.
One idea would be to prefix or suffix one of the methods with an
underscore. I'll think about that too. Not sure which one.... Following
Ruby, I could suffix the destructive method with an underscore.
e.g. Set union(Set s) - non-destructive - i.e. returns the result as
a Set
boolean union_ (Set s) - updates "this" (returns true if "this"
set changed).