On Fri, Mar 25, 2005 at 03:47:43PM -0800, Greg Buchholz wrote: : : I'm wondering if the precedence of the "return" keyword isn't wrong : in pugs. In the code below, fibo2 works as I'd expected, fibo returns : nothing. (If this is expected behavior, I'd apppreciate someone : pointing me to TFM). : : Thanks, : : Greg Buchholz : : : #!perl6 : use v6; : : sub fib ($n) { return ($n<2) ?? 1 :: fib($n-2) + fib($n-1) } : sub fib2 ($n) { return (($n<2) ?? 1 :: fib2($n-2) + fib2($n-1)) } : : my $x = fib(6); : say " fib(6)=$x"; : : my $y = fib2(6); : say "fib2(6)=$y";
Both of those ought to work. I think return should parse like a list operator, if it parses like anything else. Larry