# I've been reading a book on symmetry lately(http://is.gd/MGST), # and the other day it touched on something interesting that it # turns out my code could have benefited from very recently: # Modular Arithmetic # The use case was cycling through indexes of an array. # I had an operation that I wanted cycle through an array of values # for use each time it was run. # Instead of something like this... def rotate_index new_value = index + 1 new_value = 0 if new_value >= array.size set_index(new_value) end # You could say this... def rotate_index set_index((index + 1) % array.size) end # Math strikes again!