Can anyone explain this code:
dates = (from_date..to_date).map(&:to_s)
So that it helps me to do the project!
Thanks in advance!
Can anyone explain this code:
dates = (from_date..to_date).map(&:to_s)
So that it helps me to do the project!
Thanks in advance!
 
    
     
    
    Generally map creates a new array containing the values returned by the block. What you are doing here is: defined two function from_date & to_date and which return(I assume) two dates and then converting it to array of date range from from_date to to_date
2.0.0-p648 :010 > date = Date.today.prev_day
 => #<Date: 2017-08-09 ((2457975j,0s,0n),+0s,2299161j)> 
2.0.0-p648 :011 > (date..Date.today).map(&:to_s)
 => ["2017-08-09", "2017-08-10"] 
2.0.0-p648 :012 > 
