3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pryでもrubyのnextを使いたい!そんなときの対処法

Posted at

環境

pry (0.10.4)
pry-nav (0.2.4)
pry-rails (0.3.6)

rails consoleでnextが使えない

[1] pry(main)> 1.upto(3) do |num|
[1] pry(main)*   next if num > 1
Error: Cannot find local context. Did you use `binding.pry`?

nextはpry-navでの予約語で使えません :cry:

Pry::Commands.deleteを使って解決 :hugging:

[2] pry(main)> Pry::Commands.delete 'next'
=> ["next"]
[3] pry(main)> 1.upto(3) do |num|
[3] pry(main)*   next if num > 1
[3] pry(main)*   puts num
[3] pry(main)* end
1
=> 1

consoleをexitすると初期化されるので、常にoffっておきたい場合は.pryrcに書いておくと良いそうです :bulb:

現場からは以上です。

参考

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?