Recently I saw this decision making in a ruby code:
if __FILE__ == $0
....
Then I had to print __FILE__
and $0
separately on irb and I saw that the two pass the same information, my doubts are:
- Why (when) do this comparison?
- Why not compare with the same command (
__FILE__ == __FILE__
)? - Is there any method to get the filename directly by
__FILE__
without having to filter?