# Value length operator

The length operator # applied on a Value object returns the size in bytes of the C Value in memory.

Notes

  • The length operator returns the same result as the Value.size property.
  • For C strings and wide strings, the length operator includes the last zero character.

Example

local c = require "c" local c_str = c.string("LuaRT") local c_wstr = c.wstring("LuaRT") -- should print 6 (C string of 5 characters with the last zero character) print(#c_str) -- should print 12 (C wide string of 5 characters with the last zero character) print(#c_wstr)