Skip to content

Instantly share code, notes, and snippets.

@haio
Created January 30, 2013 02:41
Show Gist options
  • Save haio/4670140 to your computer and use it in GitHub Desktop.
Save haio/4670140 to your computer and use it in GitHub Desktop.
if __FILE__ == $0
if __FILE__ == $0
__FILE__ 是一个魔法值,它存有现在运行的脚本文件的名字。$0 是启动脚本的名字。 代码里的比较结构的意思是 “如果这是启动脚本的话...” 这允许代码作为库调用的时候不运行启动代码, 而在作为执行脚本的时候调用启动代码。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment