CommandHelper

CommandHelper

46.5k Downloads

funkiness with array_get() failures (Feature Request)

LadyCailinBot opened this issue ยท 1 comments

commented

CMDHELPER-2824 - Reported by VergilPrime

I would appreciate array_get() returning null instead of throwing errors like CastExceptions when the array specified doesn't exist or is not associative.

This would make it easier to handle objects like items that may or may not have certain arrays present.

Example:
pinv(player,null) == {data: 0, enchants: {}, meta: null, qty: 1, type: 2}
if(pinv(player,null)[meta][displayname] != null) will not return if the value does or doesn't exist, it will simply error to hell if it doesn't.

commented

Comment by LadyCailin

array_get, when used as a function, has a third parameter, default. This should suit your needs, and won't break everyone's code.