I think it’s especially weird if you take C code (or most other languages) and directly translate it to Lua. On the other hand, if you change your naming conventions to fit it can be very elegant IMO.

A bad example: if shirt:isdirty() then wash() end.

If you see then and end as syntax, it’s kinda the same thing. then == {, and end == }.

3 Likes

the way i approached the book was to make notes about anything i found weird coming to it from java/c#/c background. there are several notes that end with “really?!” or “wtf?”. i think one was about the way the ternary if is done…

lua’s ternary if kinda feels like a secret key combo power move in a video game : )

not highly readable though, especially when the condition has and or or

1 Like

yep! this all sounded familiar, that’s because i posted about it before: (grid) Code examples

I had a laugh writing this today

return (type(x) == 'number') and ((i > 1) and 0 or x) or (x[i] or x[i-1] or ((i > 1) and 0 or x[1]))

(it works!)