in reply to Re^2: A question about method return values and error checking
in thread A question about method return values and error checking
If you return empty strings on failure instead of undef, then you'd need to use || instead of //, which could cause issues if 0 is a potential return value. (Not likely in the specific example of OS name/version, but relatively common in the general case.) So, personally, I'd chalk that up as another point in undef's favor.printf <<EOF, $os->name( long => 1 ) // 'unknown OS', $os->version // +'unknown version'; Operating System: %s Version : %s EOF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: A question about method return values and error checking
by kennethk (Abbot) on Nov 05, 2015 at 15:13 UTC | |
by tye (Sage) on Nov 05, 2015 at 16:03 UTC | |
by kennethk (Abbot) on Nov 05, 2015 at 21:10 UTC | |
by Anonymous Monk on Nov 06, 2015 at 11:15 UTC | |
by dsheroh (Monsignor) on Nov 06, 2015 at 11:03 UTC | |
|
Re^4: A question about method return values and error checking
by Anonymous Monk on Nov 05, 2015 at 09:57 UTC |