firstchar
function firstchar( str ) --> charstr
Description
Returns the first char in a string. If the string is empty returns the function an empty string.
Parameters
- str
-
The source string.
Return Values
- charstr
-
The first char value.
Code
--ZFUNC-firstchar-v1 local function firstchar( str ) --> charstr return string.sub( str, 1, 1 ) end return firstchar
Examples
local t = require( "taptest" ) local firstchar = require( "firstchar" ) t( firstchar( "abc" ), "a" ) t( firstchar( "" ), "" ) t()