Project

General

Profile

Feature #21155

Updated by artur86 (Artur *) 10 days ago

Given there is a class that needs to be namespaced.  

 `module` requires indenting the class by one level: 

 ```ruby 
 module MyNamespace 
   class MyClass; end 
 end 
 ``` 

 Scope resolution operator (`::`) 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 
 ``` 

 What if something similar to [File Scoped Namespaces in C#](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) would be implemented in Ruby? 

 The concept is very clearly formulated in [a question on StackOverflow](https://stackoverflow.com/q/40809717/2987689) and sounds like basically states as "everything in this file should be in some module". module", as it is formulated in [a question on StackOverflow](https://stackoverflow.com/q/40809717/2987689).

Back