Code Editor
Learn
Object-Oriented Programming II

Resolve to Keep Learning

One of the main purposes of modules is to separate methods and constants into named spaces. This is called (conveniently enough) namespacing, and it's how Ruby doesn't confuse Math::PI and Circle::PI.

See that double colon we just used? That's called the scope resolution operator, which is a fancy way of saying it tells Ruby where you're looking for a specific bit of code. If we say Math::PI, Ruby knows to look inside the Math module to get that PI, not any other PI (such as the one we created in Circle).

Let's get some practice in with an existing Ruby module: Math.

Report a Bug
If you see a bug or any other issue with this page, please report it here.