mercredi 30 avril 2014

ruby difference between last range and the next first range


Vote count:

0




I have a range as follows:



my_range = [1297134..1328348, 1381732..1382716, 1406478..1408262, 1425452..1427966, 1607341..1609354, 1616388..1616625, 1844576..1846076, 1847450..1847672]


I like to loop through all these ranges and find the difference between the last range and the next first range, so for example:



1381732 - 1328348
1406478 - 1382716
etc..


I know there is the .first and .last methods but I have no idea how to state the the last range and the next first range. Would appreciate some help.


Thanks



asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire