add mrb_ary_modify(mrb,a); you have to ensure mrb_value a to be an array; ref #1554