Avoiding Naming Collisions with Namespaces
module StringTheory
class String
def initialize(length=10**-33)
@length = length
end
end
end
String.new # => ""
StringTheory::String.new
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"
Related examples in the same category