From: Karen Etheridge Date: Wed, 14 Nov 2012 21:02:01 +0000 (-0800) Subject: add alternative mechanisms for fallback return values X-Git-Tag: Try-Tiny-0.12~4^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c065237ef7bd2d8fd85f1769c89c7dddd1392805;p=p5sagit%2FTry-Tiny.git add alternative mechanisms for fallback return values --- diff --git a/lib/Try/Tiny.pm b/lib/Try/Tiny.pm index 3546b3a..18b91a3 100644 --- a/lib/Try/Tiny.pm +++ b/lib/Try/Tiny.pm @@ -198,10 +198,12 @@ of error values (simple strings, references, objects, overloaded objects, etc). If the try block dies, it returns the value of the last statement executed in the catch block, if there is one. Otherwise, it returns C in scalar -context or the empty list in list context. The following two examples both +context or the empty list in list context. The following examples all assign C<"bar"> to C<$x>. my $x = try { die "foo" } catch { "bar" }; + my $x = try { die "foo" } || { "bar" }; + my $x = (try { die "foo" }) // { "bar" }; my $x = eval { die "foo" } || "bar";