I have an interval let's say (0..3) where next element is +1 unless the last. Then the next is 0. I solved it by the code below. Just wondering if there is anything else outhere :-)
def next(max,current)
if current+1 == max
return 0
else
return current+1
end
end
EDIT
please note that when the code runs I need to be able to assign any 'valid number' in my example 0..3 at any time.