如何将第一个元素移到数组的末尾 [英] How to move first element to the end of array

查看:1091
本文介绍了如何将第一个元素移到数组的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将数组的第一个元素移动到同一数组的末尾的最佳方法是什么?

What is the best way to move the first element of the array till the end of this same array?

即:[a,b,c,d]

某些操作"

结果:[b,c,d,a]

某些操作"应该是什么?

What should this "Some operation" be?

推荐答案

Array#rotate :

[a,b,c,d].rotate(1)

这篇关于如何将第一个元素移到数组的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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