Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: on to better coding (no uninitialized values)

by echo (Pilgrim)
on Aug 23, 2001 at 21:16 UTC ( [id://107411]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://107411]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found