ArpeggioAndy
ArpeggioAndy
CC#
Created by ArpeggioAndy on 2/3/2025 in #help
Enumerable.OrderBy help
I'm following a tutorial and they randomly get an element of an enumerable like this:
return unvisitedCells.OrderBy(_ => Random.Range(0, 10)).FirstOrDefault();
return unvisitedCells.OrderBy(_ => Random.Range(0, 10)).FirstOrDefault();
I'm a bit confused as to how this works. I looked up the docs for .OrderBy and kind of understand how it's usually meant to be used, but I don't see what throwing a random number in there does exactly.
23 replies