if (!$variable1) {
$variable1 = 'default';
}
unless (defined($variable2)) {
$variable2 = 'default';
}
can be done much more quickly as$variable1 ||= 'default'; # true or $variable2 //= 'default'; # defined ori prefer the second
When I started this blog, my intent was to illustrate different ways to do things in Perl (where TIMTOWTDI originated). Since then I have transitioned from Perl to Python, become active in several open source software projects, and started to learn how to contribute to project code in addition to test automation. I am returning to the blog to discuss things as I learn them. 'There's More Than One Way To Do It' remains true, even using different languages or an established design pattern.
No comments:
Post a Comment