Lua is insane.

> _VERSION Lua 5.4

…how do you get the 5.4 part in lua?

> string.sub(_VERSION, (string.find(_VERSION, " ")) + 1) 5.4

The parentheses around the string.find call are necessary. string.find for some reason returns startpos, endpos. With parentheses, all other return values are discarded. Experimenting upon learning this:

> function a() >> return 3, 21 >> end > a function: 0x55750597e2c0 > a() 3 21 > (a()) 3

@applejack Mainly wondering about working with multiple return values in this post, but thanks.

@mar77i They made the decision to only keep one if the function is not at the end since it can nudge it off by one.

Functions like assert(io.open("file.txt")) will work as expected. Takes everything as a param, so, if it gets nil it prints the second value

Otherwise it requires something like that

@applejack Don't C-like languages evaluate to the last item in a comma-separated list?
Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.