in reply to Re: What to test in a new module
in thread What to test in a new module
It's a case of TIMTOTWDI, and I have not looked at the original code, but two comments:
No need for this: $self->{'error'} = '';. It'll be autovivified if needed.
It will autovivify as undef if it is not assigned to before it is accessed. That could cause issues later on with other code.
There's no need for a return; at the end of a sub if nothing's being returned (unless you intentionally are returning undef.
It's safer to explicitly return as otherwise the value of the last expression is returned. FWIW, this is covered in PBP on p197 under Implicit Returns, with a follow-on under Returning Failure on p199 (although that also encourages the Contextual::Return module which I don't use).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: What to test in a new module
by jdporter (Paladin) on Jul 07, 2023 at 13:50 UTC | |
by swl (Prior) on Jul 08, 2023 at 05:56 UTC | |
by jdporter (Paladin) on Jul 10, 2023 at 14:14 UTC | |
by choroba (Cardinal) on Jul 11, 2023 at 18:22 UTC | |
by jdporter (Paladin) on Jul 11, 2023 at 18:43 UTC |