[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String represents arrays of characters.
- From: Petite Abeille <petite.abeille@...>
- Date: Mon, 13 Dec 2010 22:31:14 +0100
On Dec 13, 2010, at 10:27 PM, Jonathan Castello wrote:
> If you're going to use __call, why not drop __index altogether? I
> don't really like having two different syntaxes for what's arguably
> the same operation.
As you wish :P
getmetatable( '' )[ '__call' ] = function( self, a, b ) return self:sub( a, b or a ) end
print( #aString, aString( 1 ) )
print( #aString, aString( 1, 2 ) )
print( #aString, aString:upper() )
> 3 a
> 3 ab
> 3 ABC