LoginSignup
0
0

More than 3 years have passed since last update.

Rubyでゼロ埋め(0埋め)しようとしたらrubocopさんに怒られる

Posted at

問題

rubocopさんが怒ってきた...怖い...

C: Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s).
        format('number: %03d', 1)
                        ^^^^

解決方法

formatでは、hashを用いて、引数指定を設定できるので、そちらで回避します。

format("number: %03<number>d", number: 1)
#=> "number: 001"

参考

0
0
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
0
0