Joe*_*ann 4 ruby module pointer-aliasing
我有一个名为的模块Setup,想要为方法添加别名.
这是它的外观,但它是如何工作的:
module Setup
def Setup::option_set?(option)
#...
end
alias :option_set? :get_information
end
Run Code Online (Sandbox Code Playgroud)
我想这与Setup::-prefix有关.该怎么办?
module Setup
class << self
def option_set?(option)
#...
end
alias :get_information :option_set?
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2687 次 |
| 最近记录: |