Re: Accessing String contents
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Accessing String contents
- From: Geoff Leyland <geoff_leyland@...>
- Date: 2012年6月21日 15:49:07 +1200
On 21/06/2012, at 3:43 PM, Coda Highland wrote:
> Strings are tables, but the characters aren't table elements. Lua
> doesn't offer that sugar.
But you can always do it yourself:
Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> debug.setmetatable("", { __index=function(s, i) return string.sub(s, i, i) end })
> =("hello")[5]
o