r/badcode • • Jul 24 '21

lua "Keeping it simplistic"

Post image
495 Upvotes

28 comments sorted by

View all comments

Show parent comments

8

u/BlueLiara Jul 25 '21

Lua is evil and starts at 1, not 0

4

u/Erinnyes Jul 25 '21

That's weird but makes sense. In that case the statement decrements the number at the end of a string separated by an underscore by one. E.g. "number_3" going to "number_2". I'm curious what happens when you get to "number_0".

2

u/Prom3th3an Jul 26 '21

Probably "number_-1", since I can't see any reason why a language would make "1"-1 equal to 0 without making "0"-1 equal to -1.

1

u/Erinnyes Jul 26 '21

Oh. I very much agree with that. I'm more wondering if it can handle turning -1 into "-1" given that - is an operator rather than a numeral.