[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: string.gsub and its need for variables..
- From: The Doctor <the_doctor@...>
- Date: Sun, 29 Aug 2004 20:12:18 +0100
Hello, a question about string.gsub and returned values..
If I do:
io.write(string.gsub("Concatenation, Catharsis, Popocatapetl\n","cat","dog"))
I get the count appened to the output, whereas to get the string only, I'd have to do this:
local X=string.gsub("Concatenation, Catharsis, Popocatapetl\n","cat","dog")
io.write(X)
Thing is, might it not be better to have this the other way round, so that we don't need to make a variable if we don't want to re-use the output? That way we only need introduce extra complexity at need, by using local X,Y=string.gsub(...) when we want the match count.
(One of the things I liked in Lua4 was the X,Y=Y,X method of swapping without making an intermediate variable, yet now we have to make one where we once did not, it seems..)
I ask this not because I'm too lazy to put up with it; I'm not.. :) I ask because an informed answer might go a long way toward helping me with Lua5.