I go into irb
and require a file
irb> require_relative 'prime'
irb> true
This file contains the following code:
def is_prime? num
(2..num-1).each do |div_by|
if num % div_by == 0
return false
end
end
true
end
requiring the file in irb works and I can use the method, e.g.
irb> require_relative 'prime'
irb> is_prime? 10
irb> -> false
irb> is_prime? 11
irb> -> true
However if I modify the source file, say add puts 'HHH'
, that does not show up unless I exit the console and re-enter and then require
the file
If I stay in the console and require the file again I get false as it is already loaded and I don't get the new changes
I have tried
irb> reload
and
irb> reload!
but they give me
NoMethodError (undefined method `reload!' for main:Object)
Also I tried
irb> load 'prime.rb'
irb> => true
but did not pick up the change
Using PRY gave similar results