If __FILE__ == $Program name


#1

Hi there,

I have just started the Ruby final exercise and the first thing it asks is to type a runner code to start the program.

I was lost and looked at the solution offered, while it made my program run, i have never seen this before:
if FILE == $PROGRAM_NAME
my_list = List.new
puts “You have created a new list”
end

Could someone explain to me what the first line of code actually does? I understand that it is an if statement checking if the file equals the program name, but the purpose of __ & __ either side i am unclear on? and is PROGRAM NAME something in built to ruby?

Thanks in advance!