lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jul 2, 2008 at 3:00 PM, Peter LaDow <pladow@gmail.com> wrote:
> Thanks to everyone for their help earlier with the side effects.  The
> sandbox approach will work for me.
>
> Now on to the next issue.  Can somebody explain why I get different
> results using print with the concatenation operators and using the
> strings as separate arguments.  I presume it has something to do with
> calls to tostring(), but it isn't clear.
>
> For example, assume key hold "hello" and value holds "world".  Doing this:
>
> print("'", key, "' = '", value, "'")
>
> I get:
>
> '       hello   ' = '   world   '
>
> And doing:
>
> print("'" .. key .. "' = '" .. value .. "'")
>
> I get:
>
> 'hello' = 'world'
>
> Where do the extra spaces come from in the former case?

Lua adds a tab character between arguments to print, and a newline
after printing all arguments.

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant