There seems to be a conflict in the version of Ruby expected, and the one present. In newer versions,
.new is gone, and so is
.next as I understand it. Consequently the currently prescirbed code does not execute properly. Without some confirmation from the dev team, it’s impossible to say what the issue truly is–Version or SCT?
Prime.new can now be written as
Prime.instance and the array no longer needs to be declared since the above method returns an array.
What’s interesting is that we can run the same methods on the Class as on the instance so it is not even necessary.
Anyway, it will take some follow-up reading to get to the bottom of the changes in Ruby, and I will need to find out just what the issue is with this lesson. I do know that the newer version syntax does work so have a strong suspicion the issue here is version related.
Following is code that will work. It is stripped right down to only the essential code needed to complete the assignment. I’ll leave it with you to uncover the logic behind it.
"n must be an integer." unless n.is_a? Integer
"n must be greater than 0." unless n > 0
Sorry I couldn’t be more help. Dig around this category for the topic where I explained how this code came to be. It took me an afternoon to figure it out.