且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

相当于Ruby中的`if __name__ =='__main __'`

更新时间:2022-04-01 05:11:18

在Ruby中,我从野外看到(当然,不是一吨),这不是标准的Ruby设计模式.模块和脚本应该保持独立,因此,如果没有真正好的,干净的方法,我也不会感到惊讶.

From the Ruby I've seen out in the wild (granted, not a ton), this is not a standard Ruby design pattern. Modules and scripts are supposed to stay separate, so I wouldn't be surprised if there isn't really a good, clean way of doing this.

编辑:但这绝对不常见.