如何更改数组元素的位置? [英] How to change the position of an array element?

查看:235
本文介绍了如何更改数组元素的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于如何更改数组元素的索引的问题,以使它不位于7.位置,而位于2位置...

I have a question on how I can change the index of a array element, so that it doesn't come at the 7. position but at position 2 instead...

有处理此问题的功能吗?

Is there a function to handle this?

推荐答案

没有什么比这更简单了:

Nothing is simpler:

array.insert(2, array.delete_at(7))

这篇关于如何更改数组元素的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆