ID:173355
 
if, for example, after messing around with a list that belongs with a player, i go and:
(Where LIST is a players list)

LIST = null

Does this just empty the variable?, I've used it a number of times it makes sence that it does, but, just to be safe...
Thanks in advance.

-Thorg
Depends what you mean by "empty". It won't only clear the contents of the list; it will delete the list. (Actually, it won't delete the list by itself; it'll just leave the list hanging, to be deleted by the garbage collector). So the list won't actually exist, meaning you can't add to it or anything.

A safer way is to use list.Cut(). Using your example:

<code>LIST.Cut()</code>
In response to Crispy
Crispy wrote:
A safer way is to use list.Cut(). Using your example:

<code>LIST.Cut()</code>

Of course, it depends on what you want to do. If you don't need the list anymore, setting the var to null is just as good an approach.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Crispy wrote:
A safer way is to use list.Cut(). Using your example:

<code>LIST.Cut()</code>

Of course, it depends on what you want to do. If you don't need the list anymore, setting the var to null is just as good an approach.

Lummox JR

LIST=list() is always good, too.

~>Volte
In response to Volte
Volte wrote:
LIST=list() is always good, too.

Actually if the goal is to keep an active list, then LIST.Cut() is the best solution, because the other way you're deleting the old list and creating a new one; it's a lot less efficient.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
...because the other way you're deleting the old list and creating a new one; it's a lot less efficient.


Ah, didn't know that. I thought it just set the variable to an empty list. Thanks for this information. :)

~>Volte