Ruby相当于Python __main__

Rod*_*gue 11 ruby python program-entry-point

如果在ruby文件中我定义了这样的函数:

def tell_the_truth()
    puts "truth"
end
Run Code Online (Sandbox Code Playgroud)

有没有相当于python的主要?

if __name__ == "__main__":
    tell_the_truth()
Run Code Online (Sandbox Code Playgroud)

是简单地调用文件中的函数吗?

tell_the_truth
Run Code Online (Sandbox Code Playgroud)

rob*_*ert 25

我相信这会奏效:

if __FILE__ == $0
    tell_the_truth()
end
Run Code Online (Sandbox Code Playgroud)