kiyo_hikoのブログ

メモ+日記?

2017-04-26から1日間の記事一覧

Rubyでゼロ埋め文字列 (printf %0s的な何か)

なんとなく必要になって書きました。 def printf_0n(n, str) n <= str.length and return str "#{1.upto(n - str.length).map{0}.join}#{s}" end