You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a = 5
4.times.map do
a = 3
# next a
next "#{a}"
end
in string interpolation, the variable a get the value of outside block 5 instead of 3
without string interpolation or using .to_s, it keeps the value 3
➜ ~ pry
[1] pry(main)>
[2] pry(main)> a = 5
=> 5
[3] pry(main)> 4.times.map do
[3] pry(main)* a = 3
[3] pry(main)* # next a
[3] pry(main)* next "#{a}"
[3] pry(main)* end
=> ["5", "5", "5", "5"]
➜ ~ irb
2.2.5 :001 >
2.2.5 :002 > a = 5
=> 5
2.2.5 :003 > 4.times.map do
2.2.5 :004 > a = 3
2.2.5 :005?> # next a
2.2.5 :006 > next "#{a}"
2.2.5 :007?> end
=> ["3", "3", "3", "3"]
Versions used :
➜ ~ pry -v
Pry version 0.11.3 on Ruby 2.2.5
➜ ~ irb -v
irb 0.9.6(09/06/30)
[1] pry(main)> a = [1,2,3]
=> [1, 2, 3]
[2] pry(main)> a.each do |num|
[2] pry(main)* break num if num > 2
[2] pry(main)* p num
[2] pry(main)* end
1
2
=> 3
In pry-byebug:
[1] pry(main)> a = [1,2,3]
=> [1, 2, 3]
[2] pry(main)> a.each do |num|
[2] pry(main)* break num if num > 2
ArgumentError: Cannot identify arguments as breakpoint
from /Users/hegwin/.rvm/gems/ruby-2.5.3/gems/pry-byebug-3.0.1/lib/pry/commands/breakpoint.rb:114:in `new_breakpoint'
[2] pry(main)* p num
[2] pry(main)* end
1
2
3
=> [1, 2, 3]
pry-byebug seems to alter next/break behaviors
using this snippet of code
in string interpolation, the variable
a
get the value of outside block5
instead of3
without string interpolation or using
.to_s
, it keeps the value3
Versions used :
Gemfile.lock :
(originally posted on pry : pry/pry#1717)
The text was updated successfully, but these errors were encountered: