Rubyでゼロ埋め文字列 (printf %0s的な何か)
なんとなく必要になって書きました。
def printf_0n(n, str) n <= str.length and return str "#{1.upto(n - str.length).map{0}.join}#{s}" end
なんとなく必要になって書きました。
def printf_0n(n, str) n <= str.length and return str "#{1.upto(n - str.length).map{0}.join}#{s}" end