What about both directions [ < Infinitely > ]. Sometimes going to the right around the world is much longer than stepping left directly to your destination.
Thought more about this, and I don’t know of a clever solution outside of the developer using some heuristic to determine direction. For example, if you know your array is sorted, you could use the size of the item you are looking for [along with the value of the first and last item] as a signal in which direction to cycle by.
This response confused me for a while until I realized you were talking about how to know when to go left or right and not simply providing the option of going left or right
Haha! Yes. After a day full of Slack convos, e-mails, and talking, my brain is a at the point I wrote my earlier response
Now I am hungry.