#author("2021-12-17T11:23:43+00:00","default:hotate","hotate") &tag(Ruby, Tips); #author("2023-06-04T00:02:50+00:00;2021-12-17T11:23:43+00:00","default:hotate","hotate") &tag(Ruby,Tips); * 引数 [#z65c9235] - [[メソッドの引数にアスタリスク - Qiita>https://qiita.com/super-mana-chan/items/ca728d90db7c53295b15]] そもそもの引数の話として、アスタリスクがついた引数を、アスタリスク1つなら可変長引数、アスタリスク2つならオプション引数という。 * [[ログ]]出力 [#m80da4ff] - [[ruby - Putting the results of pp (or anything outputted to console) into a string - Stack Overflow>https://stackoverflow.com/questions/15284694/putting-the-results-of-pp-or-anything-outputted-to-console-into-a-string]] string_value = a.pretty_inspect #pretty_inspect also comes along when you first require 'pp' - See: http://ruby-doc.org/stdlib-2.1.0/libdoc/pp/rdoc/Kernel.html#method-i-pretty_inspect - [[Word,Excel,PowerPointをPDFに一括変換>https://gist.github.com/oxoofo/786366/b07772cb4380ecb3b4b5ccbcba9d628b8963a144]] def puts(*args) STDOUT.puts(*args) @logfile.puts(*args) end -- コメント:標準出力とファイル出力の両方を行うコード例 (2021/12/17) * メソッド [#t0024d9b] - [[Rubyでメソッドがあるかをrespond_to?で調べました。 - Qiita>https://qiita.com/pugiemonn/items/9667d44da06657603de1]] 調べたいオブジェクトでrespond_to?を使用します。