We’re going to reinforce our knowledge of Ruby best practices by refactoring some existing code. As mentioned, refactoring is the process by which we improve a code’s structure, appearance, and/or performance without modifying its overall behavior.
The code in the editor is a Ruby method,
first_n_primes, that takes a number n and generates a list of the first n prime numbers. Unfortunately, our poor author hasn’t yet mastered all the tools available in Ruby. But we can fix that!
Let’s get to work and start refactoring this monster of a program!