Actually, this cannot be rewritten to use array.getArray. When the input is an array, return val should be an array. When input is a number, return val should be a number. Will create a convenience method if I find myself encountering this pattern a lot.