Generic index accessor for arrays