[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:20:05 +0100
On Dec 13, 2010, at 10:06 PM, Javier Guerra Giraldez wrote:
> (PS: to answer PA, that would break current (''):find() usage )
Yes, yes... I know it's dumb... but since when are we in the business of preventing people from shooting themselves in the foot?!? :P
getmetatable( '' )[ '__call' ] = function( self, a, b ) return self:sub( a, b ) end
getmetatable( '' )[ '__index' ] = function( self, key ) if type( key ) == 'number' then return string.char( string.byte( self, key ) ) end return string[ key ] end
print( #aString, aString[ 1 ] )
print( #aString, aString( 1, 2 ) )
print( #aString, aString:upper() )
> 3 a
> 3 ab
> 3 ABC