Search code examples
programming-languages

What is a Namespace?


I didn't take the usual CS route to learning programming and I often hear about namespaces but I don't really understand the concept. The descriptions I've found online are usually in the context of C which I'm not familiar with.

I am been doing Ruby for 2 years and I'm trying to get a deeper understanding of the language and OOP.


Solution

  • A namespace provides a container to hold things like functions, classes and constants as a way to group them together logically and to help avoid conflicts with functions and classes with the same name that have been written by someone else.

    In Ruby this is achieved using modules.