|
The Doctor wrote:
Thankyou :) I like the brackets, that's a neat answer and the one I'll use. The function is ok too, though I'd only do that if I wanted further modification, probably. That said, isn't it strange that there should be special requests for a minimum default? In most things in life we might only want extra information if we ask for it, and Lua, by doing the reverse of this, seems to risk losing the easy and clarity it is so good at.
It's not a special request; gsub *always* returns multiple values. It's just that if you just say x = string.gsub(...) then all except the first one are discarded. It just so happens that if a function that returns multiple values is the last item in an argument list or a table definition, then all the values are appended. If you'd done: io.write(string.gsub(...), 4) ...then you would have seen the expected result (one string followed by a 4). So Lua is behaving completely consistently, if a little unintuitively. -- [insert interesting .sig here]