What does the double column "::" mean in : class XML::Attributes

What does the double column “::” mean in:

class XML::Attributes

Is it

  • A class
  • A method.
  • Part of the definition of a class.
  • A further namespace inside a class?

It’s a namespace separator, which separates the diff namespaces a type/const is in.

module Foo
  class Bar
    BAR = "BAR"
  end
end

class Baz
  module SomeMod
    record SomeStruct
  end
end

Foo::Bar.new
Foo::Bar::BAR # => "BAR"
Baz::SomeMod::SomeStruct.new
2 Likes

Also, if you do class XML::Attributes and XML wasn’t defined before, it’s defined as a module.

1 Like

I suppose, the idea is to regroup related classes under one hood, using modules as namespaces (somehow like std:: in C++)?

https://crystal-lang.org/reference/syntax_and_semantics/modules.html

1 Like