“layerstate列表”符号是一个函数,而不是一个变量。”stateList’是该函数中用于保存列表的变量,该变量由函数返回(因为它是函数中计算的最后一个表达式)。
否,“/”将“/”后面的符号声明为函数的局部符号,这意味着这些符号存在于该函数的“命名空间”(容器)中。这意味着这些变量在函数使用时所持有的值无法访问,并且不会干扰函数外部。
考虑这个例子:
当运行时,上述将返回:
- "Kam" - Value held by 'test' outside of function namespace
- nil - Since 'test' is local to the function, the symbol has no value in the function namespace yet.
- "Lee" - Value now held by 'test' symbol in the function namespace
- "Kam" - Value held by 'test' outside of function namespace
- (not changed by the value of 'test' inside the function namespace)
|