With Date's downto method, count down five days, displaying each date as you go (this makes in-place changes to the date) : downto « Date « Ruby






With Date's downto method, count down five days, displaying each date as you go (this makes in-place changes to the date)


require 'date'

date = Date.new( 2006, 11, 8 )

date.downto( date - 5 ) { |date| puts date }

# date has changed
date.to_s # => "2007-11-03"

 








Related examples in the same category