[Koha-bugs] [Bug 14641] Warns in subscription-add.pl

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Jan 11 10:36:32 CET 2016


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14641

--- Comment #7 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
The verbose way to do it is:

    my ($selected_lettercode) = @_;
    if ( not defined $selected_lettercode ) {
        $selected_lettercode = '';
    }

A better way, IMO is to use `unless` instead of `if not`

    my ($selected_lettercode) = @_;
    unless ( defined $selected_lettercode ) {
        $selected_lettercode = '';
    }

A much more better way is to do the same but more readable (because less
verbose):

    my ($selected_lettercode) = @_;
    $selected_lettercode //= '';

`//=` means `assign what is at the right if what is at the left is not defined`

`||=` would means `assign what is at the right if what is at the left is not
defined or is 0 or is an empty string`

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list