Methods, Blocks, & Sorting - Why Methods? code has a bug



If you test the default code with non-integer inputs either it passes it as prime! (in case of floats) or it exits with an error. Both cases are examples of buggy or poorly designed code.

The culprit is in the very first line after the function head:

  puts "That's not an integer." unless n.is_a? Integer

I've made a very simple modification which removed the bug/error. Replace the code line above with these lines:

    unless n.is_a? Integer
      puts "#{n} is not an integer" 


Please post a link to the exercise. Thank you.


1/19 Methods, Blocks, & Sorting