[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: String access & metamethods
- From: "Carlos Augusto Teixeira Mendes" <cmendes@...>
- Date: Wed, 12 Dec 2007 20:45:02 -0200
Be carefull with concatenation operations.
In the code:
getmetatable("").__tostring=function (x) return "<<<"..x..">>>" end
a = "foo".."bar"
print(a)
you will get <<<foobar>>>
and not <<<foo>>><<<bar>>> as you might be expecting for your translation
requirements.
Carlos Augusto.
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Luiz
> Henrique de Figueiredo
> Sent: Wednesday, December 12, 2007 8:27 PM
> To: Lua list
> Subject: Re: String access & metamethods
>
>
> > OK, so that's just brilliant, and was exactly what I was
> looking for. Now
> > the question is, what am I potentially getting myself into by
> overwriting
> > the __tostring metamethod?
>
> The __tostring metamethod is only used in print and in tostring; it's not
> a core metamethod. I'm not sure this answers your question but
> there it is.
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date:
> 12/11/2007 5:05 PM
>
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.503 / Virus Database: 269.17.1/1181 - Release Date: 12/11/2007
5:05 PM