Last active
December 21, 2015 01:29
-
-
Save yancya/6228365 to your computer and use it in GitHub Desktop.
連続した年月の文字列を出力する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rjust をいつも忘れる | |
(2011..2013).each{|y| (1..12).each{|m| print [y.to_s, m.to_s.rjust(2, "0")].join('-') + ' '}} | |
# こっちの方がスマートかも | |
(2011..2013).to_a.product((1..12).map{|n| n.to_s.rjust(2, "0")}).map{|a| a.join("-")}.join(" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment