Feature #21155
Updated by artur86 (Artur *) 16 days ago
Given there is a file with a class that needs to be namespaced. There are basically two options currently. options. `module` implies requires indenting the class by one level: ```ruby module MyNamespace class MyClass; end end ``` Scope resolution operator (`::`) needs no indentation, does not require it, but it works differently than using `module` and repeating module name for every class inside seems tedious and verbose to me: ```ruby class MyNamespace::MyClass; end class MyNamespace::MyAnotherClass; end class MyNamespace::OneMoreClass; end end ``` Neither options enables Wouldn't it be better to declare a namespace once be able to say `module MyNamespace` at the top of a the file once and let expect Ruby to treat all the subsequent constants in that file to be under that namespace. namespace? This is implemented in C# under the name of [File Scoped Namespaces](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces). [The discussion The concept is very clearly formulated in [a question on StackOverflow](https://stackoverflow.com/q/40809717/2987689). StackOverflow](https://stackoverflow.com/q/40809717/2987689) and sounds like "everything in this file should be in some module".