[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why adding an extra parentheses can let function return only one return value?
- From: Coda Highland <chighland@...>
- Date: Wed, 15 Jul 2015 19:40:01 -0700
On Wed, Jul 15, 2015 at 7:37 PM, Nan Xiao <xiaonan830818@gmail.com> wrote:
> Hi all,
>
> After reading pil, I know adding an extra parentheses can let function
> return only one return value:
>
> function f()
> return 1, 2
> end
>
> print(f()) --> 1, 2
> print((f())) --> 1
>
> But the pil doesn't tell the reason behind it.
>
> Could anyone explain it? Thanks very much in advance!
>
> Best Regards
> Nan Xiao
It's pretty simple: (f()) is an expression, not a function call
(though it of course CONTAINS a function call), and expressions always
return a single value. You could also say f() + 0.
/s/ Adam