Help us understand the problem. What is going on with this article?

pry/irbの`_`

More than 5 years have passed since last update.

pryやirbで何か処理を実行したとき,結果を変数に代入し忘れたときに使う.以下pryでの実行例

[1] pry(main) > User.find_by_url_name('yaotti') # 本当はuser = User.find_by... としたかった
=> #<User id: 1, url_name: "yaotti", ...>
[2] pry(main) > user = _
=> #<User id: 1, url_name: "yaotti", ...>

Special Locals · pry/pry Wikiを読めば他の特殊変数も全部載ってるけど,_が一番便利.

その他pry関連でおすすめ記事

pryの基本: ググるよりもまずはpry
awesome_print を pry の表示のデフォルトに使う
pryを使った快適なRubyライブラリのコードリーディング&開発方法 #開発環境(未だにストッックされ続けている記事.pryのedit-methodは本当に便利)

yaotti
Qiitaを作っているIncrements株式会社の創業者
http://yaotti.hatenablog.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした