MatchData#captures
が便利.
year, month = /(.+)-(.+)-.+/.match("2012-10-27").captures
この例だったらyear, month = *date.split('-')
でもいいけど
More than 5 years have passed since last update.
MatchData#captures
が便利.
year, month = /(.+)-(.+)-.+/.match("2012-10-27").captures
この例だったらyear, month = *date.split('-')
でもいいけど
Register as a new user and use Qiita more conveniently