lua-users home
lua-l archive

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


On Wed, 25 May 2022 11:11:42 -0500
Javier Guerra Giraldez <javier@guerrag.com> wrote:

> On Wed, 25 May 2022 at 11:03, Duke Normandin <dukeofpurl@gmx.com>
> wrote:
>
> > My mistake! However I set myName = 'blah' which is a string!
> > Correct? I can then say myName = 'blah-blau' and no error
> > message shows up.
> > I'm missing something!

THANK YOU very much Javier for bottom posting your reply!
Much appreciated from this old-school noob!

> be mindful about the difference between values and variables.
>
> myName is a variable.  it can hold any value, and can be changed
> to any other value
> "blah" is a string.  it won't change.  it will always be "blah"

So a Lua string is like a string constant in C?

>
> when you change myName, it changes the variable, not the value.

That does NOT make sense to me! The variable name, i.e. myName is
not changed. The contents of variable myName has been changed to
another string.

I get it that 'blah' and 'blah-blau' are 2 different strings and
are set in stone. But I don't see the point of even bringing the
subject of string immutability unless it's in the context of they
being constants.

Duke
** Text only please. Bottom post works best for me **