3 ms·
This really depends. If your data already comes in tupels (which often happens in this case), deconstructing assignment can express very well what you are doing
by Argorak 14y ago
This really depends. If your data already comes in tupels (which often happens in this case), deconstructing assignment can express very well what you are doing.
# original
start_date, end_date = timeframe.map { |d| Date.parse(d) }
# better?
start_date = Date.parse(timeframe[0])
end_date = Date.parse(timeframe[1])
For decent Rubyists, reading a map is very easy. On the other hand, both versions are acceptable - I wouldn't bother discussing about either of the options.