Alpha course debugging - using the debugger

Help!!!
So when I try loading a ruby file in pry it works fine by displaying ‘true’ but then when I try to call the method by prime?(2) it shows error message saying "undefined local variable or method ‘prime?’ " and I am stuck at this point.
PS. I am using ubuntu and following exact instructions as mentioned in the debugging section of alpha course.
Thanks

Which exercise set are you working on? Are you sure you’ve defined a method named prime? and that it’s in the file you’re loading into pry?

Hi,

I am having the same problem on Mac. https://www.aaonline.io/alpha-curriculum/3.0/using-the-debugger

[1] pry(main)> load ‘prime.rb’
=> true
pry(main)> prime?(2)
NoMethodError: undefined method prime?' for main:Object from: (pry):6:inpry

Please share your code for best results :slight_smile:

Here is the code I am using

require ‘byebug’

def prime?(num)
debugger

(1…num).each do |idx|
if num % idx == 0
return false
end
end
end

def primes(num_primes)
ps = []
num = 1
while ps.count < num_primes
primes << num if prime?(num)
end
end

if $PROGRAM_NAME == FILE
puts primes(100)
end

This is a name collision. The file and the method have the same name, so pry can’t tell the difference. Change the name of the method or the file and try again.

Thanks! Worked out for me.