Created
December 2, 2011 16:04
-
-
Save Meettya/1423764 to your computer and use it in GitHub Desktop.
Default setter for undefined return
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
#!/usr/bin/env perl | |
use v5.14; | |
use warnings; | |
# develop mode | |
use Smart::Comments; | |
use Data::Printer; | |
sub some_function{ | |
return shift == 1 ? 1 : undef; | |
} | |
foreach(0..1){ | |
my $value = some_function($_); | |
$value //= 'default_value'; | |
p($value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment