TsT wrote:You code is ulgy and be able to break the check with metatable/__add meta handler.
Yeah, I know, it was just a joke.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Not sure if there are any advantages/disadvantages over tostring. I guess tostring is more readable, while my way is more compact (which is helpful when putting many strings and numbers together).
I think with your method, if at some point as_int accidentally is nil, it will crash, while tostring simply converts the nil value to the string 'nil'.