🖥

#Ruby の pry のドルマークで元のコードを読む的なアレはなんなのか? show-source ですよ。

2019/07/08に公開

#What is the purpose of reading the original code at Ruby's pry's dollar mark? It is a show-source.

[3] pry(main)> $ Class

From: /Users/yumainaura/.rbenv/versions/2.6.1/lib/ruby/2.6.0/json/common.rb @ line 448:
Class name: Class
Number of lines: 9

class ::Class
  # Returns true if this class can be used to create an instance
  # from a serialised JSON string. The class has to implement a class
  # method _json_create_ that expects a hash as first parameter. The hash
  # should include the required data.
  def json_creatable?
    respond_to?(:json_create)
  end
end
[2] pry(main)> show-source Class

From: /Users/yumainaura/.rbenv/versions/2.6.1/lib/ruby/2.6.0/json/common.rb @ line 448:
Class name: Class
Number of lines: 9

class ::Class
  # Returns true if this class can be used to create an instance
  # from a serialised JSON string. The class has to implement a class
  # method _json_create_ that expects a hash as first parameter. The hash
  # should include the required data.
  def json_creatable?
    respond_to?(:json_create)
  end
end

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2256

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-07-08

Discussion