[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: syntax sugar for object methods inside table constructor
- From: Sean Conner <sean@...>
- Date: Wed, 2 Jun 2021 03:28:41 -0400
It was thus said that the Great SH once stated:
> > When I see { function..., function... } my natural inclination is to see
> > those as array items 1 and 2, which they would be in the current syntax.
>
> Why? This does not resolve to a value. So why would it be assigned to [1]
> and [2] ? You cannot simply ignore the provided names.
> I don't see any ambiguity here.
The following does work:
x = { function(a) return a + 1 end , function(a) return a - 1 end }
y = x[1](1) print(y)
y = x[2](1) print(y)
-spc