Created
March 10, 2013 03:16
-
-
Save kdavh/5126962 to your computer and use it in GitHub Desktop.
Confusing behavior by Ruby Debugger using 'n' (or next) command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[5] pry(main)> prime? 5 | |
[2, 11] in /Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb | |
2 require 'debugger' | |
3 | |
4 def prime?(num) | |
5 debugger | |
6 | |
=> 7 (2..num/2).each do |i| | |
8 if (num % i) == 0 | |
9 return false | |
10 end | |
11 end | |
/Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb:7 | |
(2..num/2).each do |i| | |
(rdb:1) n | |
[3, 12] in /Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb | |
3 | |
4 def prime?(num) | |
5 debugger | |
6 | |
7 (2..num/2).each do |i| | |
=> 8 if (num % i) == 0 | |
9 return false | |
10 end | |
11 end | |
12 true | |
/Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb:8 | |
if (num % i) == 0 | |
(rdb:1) n | |
[7, 16] in /Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb | |
7 (2..num/2).each do |i| | |
8 if (num % i) == 0 | |
9 return false | |
10 end | |
11 end | |
=> 12 true | |
13 end | |
14 | |
15 def primes(num_primes) | |
16 debugger | |
/Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb:12 | |
true | |
(rdb:1) n | |
[324, 333] in /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/pry-0.9.12/lib/pry/pry_instance.rb | |
324 target = Pry.binding_for(target) | |
325 inject_sticky_locals(target) | |
326 exec_hook :before_eval, code, self | |
327 | |
328 result = target.eval(code, Pry.eval_path, Pry.current_line) | |
=> 329 set_last_result(result, target, code) | |
330 ensure | |
331 update_input_history(code) | |
332 exec_hook :after_eval, result, self | |
333 end | |
/usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/pry-0.9.12/lib/pry/pry_instance.rb:329 | |
set_last_result(result, target, code) | |
(rdb:1) n | |
[326, 335] in /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/pry-0.9.12/lib/pry/pry_instance.rb | |
326 exec_hook :before_eval, code, self | |
327 | |
328 result = target.eval(code, Pry.eval_path, Pry.current_line) | |
329 set_last_result(result, target, code) | |
330 ensure | |
=> 331 update_input_history(code) | |
332 exec_hook :after_eval, result, self | |
333 end | |
334 | |
335 # Output the result or pass to an exception handler (if result is an exception). | |
/usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/pry-0.9.12/lib/pry/pry_instance.rb:331 | |
update_input_history(code) | |
…. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment