Earlier quoted context omitted.
I don't mean to screw up the whole vibe of your comment, but... if 0 then print('0 is true') else print('0 is false') end prints "0 is true". The reason why "you can just do `if str:find('a')`" is because it returns nil. string.find never returns 0.
That's what I mean. It never returns 0, so is thus always truthy if it finds something. If you do `if (str.indexOf("a"))` in javascript; you'll miss out on the case where the string starts with "a", because the index returned 0, which is falsy. EDIT: Oh, sorry, I see what you mean. You're right, my bad. EDIT2: I guess, let me rephrase. 0 is rarely returned for things, so the falsiness of it doesn't usually enter into…
>Conditionals (such as the ones in control structures) consider false and nil as false and anything else as true. Beware that, unlike some other scripting languages, Lua considers both zero and the empty string as true in conditional tests.
https://www.lua.org/pil/2.2.html
>The basic use of string.find is to search for a pattern inside a given string, called the subject string. The function returns the position where it found the pattern or nil if it could not find it.