interesting syntax ("string" .. ...)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

interesting syntax ("string" .. ...)

Mildred Ki'Lya
Hi,

I just found an interesting syntax ... here is my code :

local log_level = 5
function log(level, ...)
        if log_level >= level then
                return print("[ "..level.." ] " .. ...)
        end
end

The interesting code is : “.. ...”
It concatenates the string "[ "..level.." ] " with the first string
in ... list

Note that it does not work without spaces (“.....”)

Just a question : it it a valid syntax ?

Mildred

--
Mildred       <xmpp:[hidden email]> <http://mildred632.free.fr/>
Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]
Reply | Threaded
Open this post in threaded view
|

Re: interesting syntax ("string" .. ...)

Roberto Ierusalimschy
> Note that it does not work without spaces (“.....”)

It does, but it has a different meaning.


> Just a question : it it a valid syntax ?

Sure. Just like '+a+++b++' is valid in C :)

-- Roberto