Jump to content

String interpolation (included): Difference between revisions

m
Line 1,260:
<lang Lua>str = string.gsub( "Mary had a X lamb.", "X", "little" )
print( str )</lang>
 
or using [string.format] function like C:
<lang lua>str1 = string.format( "Mary had a %s lamb.", "little" )
str2 = ( "Mary had a %s lamb." ):format( "little" )
print( str1, str2 )</lang>
 
=== Literal characters ===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.