What's $0 == __FILE__

__FILE__ is the name of the current source file. $0 at the top level is the name of the top-level program being executed. $0 == __FILE__ means if you are running a rb file directly. You'll often see this used in a library file that usually gets loaded from another file (so __FILE__ == $0 is false), but can also be run standalone for the sake of running tests. That's why need to add this condition.
blog comments powered by Disqus