卸载 ruby​​ 类 [英] Unload a ruby class

查看:45
本文介绍了卸载 ruby​​ 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文件 a.rb 中有以下内容:

I have the following in the file a.rb:

require foo

我需要卸载 foo,从 b.rb、c.rb 和其他文件加载 foo.

and i need to unload foo, to load the foo from b.rb, c.rb and other files.

我该怎么办?

推荐答案

Object.send(:remove_const, :Foo)

假设你的类名为 Foo.

这篇关于卸载 ruby​​ 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆