04 - avoiding naming collisions with namespaces.rb

来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 26 行

RB
26
字号
module StringTheory  class String    def initialize(length=10**-33)      @length = length    end  endendString.new                                       # => ""StringTheory::String.new# => #<StringTheory::String:0xb7c343b8 @length=1.0e-33>#---module StringTheory2 RubyString = String class String   def initialize(length=10**-33)     @length = length   end  end  RubyString.new("This is a built-in string, not a StringTheory2::String")end# => "This is a built-in string, not a StringTheory2::String"#---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?