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
@mar77i
_VERSION:match("%d.%d")
@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