Created
August 8, 2023 23:59
-
-
Save dr-kd/a8aecbb89ef0abd891909d0246db7fd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before: | |
my %thing = ( this => 'that', other => $self->my_method(@args)); | |
sub my_method { ...; return $stuff } | |
# except it's really easy for me the developer to forget to type the 'other' key | |
# which results in surprising fails | |
# So ... wantarray | |
my $thing = (this => 'that', $self->my_method); | |
sub my_method { ...; return wantarray ? ( other => $stuff ) : $stuff }; | |
# and no more surprises |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment