arnab
12/02/2016, 6:44 PMnewDirectionIndexval modifierForTurn = (if (turn == Turn.R) 1 else -1)
        val currentIndex = directionsInRightTurnOrder.indexOf(heading)
        var nextIndex = (currentIndex + modifierForTurn) % directionsInRightTurnOrder.size
        nextIndex = if (nextIndex < 0) directionsInRightTurnOrder.size + nextIndex else nextIndex
        return directionsInRightTurnOrder[nextIndex]