Replies: 1 comment 5 replies
-
You can achieve this by using |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A common problem is finding the element in an array of objects with the highest or lowest value. An example might be finding the enemy that is closest to the player. Currently, it is possible to implement this by sorting the array with
sort_custom
and taking the first element of the sorted array, but that is overkill as the array only needs to be iterated over once. You can also implement this manually with a couple of variables and afor
loop, but that's inconvenient, especially when this functionality is needed in multiple places.Adding methods
Variant min_custom(func: Callable)
andVariant max_custom(func: Callable)
to Array that returned the Variant in the array with the minimum/maximum value as returned by the given Callable would be more performant than sorting in cases where only the min/max element is needed and easier for developers to use than writing their own looping code.Beta Was this translation helpful? Give feedback.
All reactions