Skip to content

Instantly share code, notes, and snippets.

@liwh
Created February 15, 2011 06:30
Show Gist options
  • Select an option

  • Save liwh/827174 to your computer and use it in GitHub Desktop.

Select an option

Save liwh/827174 to your computer and use it in GitHub Desktop.
变量不同种类反映出它们作用的范围不同
类里面的不包含在方法里初始赋值的,有@@ 眼镜之称的是类变量,可以作用到方法里,方法们就能访问到
如果没有定义@@ 的,即使不包含到方法里,方法也访问不到
定义到方法里的,只有该方法能访问到,别的方法和类也访问不到
最宽松的是用美金开头的全局变量,只要放到程序的任何地方,都能被访问到
(你说好不好? 失去了控制不能保证访问受限,谁都能改,肯定容易出错)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment