开发者

Python-like "as" keyword (for namespacing) in Ruby

开发者 https://www.devze.com 2023-01-20 09:43 出处:网络
I was just over looking at this question.The first thought that popped to my head was that ruby must have some sort of \"as\" type keyword like Python\'s import to help avoid namespace pollution.I\'ve

I was just over looking at this question. The first thought that popped to my head was that ruby must have some sort of "as" type keyword like Python's import to help avoid namespace pollution. I've googled a bit but it seems that it's recommended to wrap your code in modules to avoid namespace problems with ruby. This seems problematic because what if two modules have conflicting names.

So, any "as开发者_JAVA技巧" type keywords for ruby's require?


What I always do is start my modules with my company initials for work or my own initials for my personal projects.

module JWG_TwitterTools
.
. 
.
end


In ruby 2.0, there will be mix (search for mix). But now, there is nothing like that... Simply use the full constant path.

0

精彩评论

暂无评论...
验证码 换一张
取 消