in reply to Re: on to better coding (no uninitialized values) in thread on to better coding (no uninitialized values)
The ||= idiom is useful for providing default values. However I've seen programmers use it extensively, precisely to get rid of the use of uninitialized value warning. I think that is not a good strategy, because it will hide bugs. A variable that is used without having been initialized illustrates a logic bug, and the warning comes in handy to warn us of this bug. Adding ||= "" to the offending line gets rid of the warning, but not of the bug. Indeed it is a useful idiom if the concept of a default value makes sense for a particular variable, but it shouldn't be abused.
|