partition.with_index
来源:互联网 发布:吉诺比利奇葩数据 编辑:程序博客网 时间:2024/05/23 16:49
I have an array filled with several dates
arry = ["06-01-2014", "07-04-2014", "14-01-2014" "14-04-2014", "16-01-2014" "27-03-2014", "30-12-2013", "31-03-2014", "27-02-2014"]
I would like to remove element 6 and up Preferably have 2 different arrays.
Is that possible?
arry = ["06-01-2014", "07-04-2014", "14-01-2014","14-04-2014", "16-01-2014", "27-03-2014","30-12-2013", "31-03-2014", "27-02-2014"]first_five = arry.shift(5)#=> ["06-01-2014", "07-04-2014", "14-01-2014", "14-04-2014", "16-01-2014"]arry #=> ["27-03-2014","30-12-2013", "31-03-2014", "27-02-2014"]
arry = ["06-01-2014", "07-04-2014", "14-01-2014","14-04-2014", "16-01-2014", "27-03-2014","30-12-2013", "31-03-2014", "27-02-2014"]first_five,rest = arry.partition.with_index{|a,i| i < 5}first_five#=> ["06-01-2014", "07-04-2014", "14-01-2014", "14-04-2014", "16-01-2014"]rest#=> ["27-03-2014","30-12-2013", "31-03-2014", "27-02-2014"]arry#=> ["06-01-2014", "07-04-2014", "14-01-2014", "14-04-2014", "16-01-2014","27-03-2014", "30-12-2013", "31-03-2014", "27-02-2014"]
0 0
- partition.with_index
- Partition
- PARTITION
- partition
- partition
- partition
- Partition
- partition
- partition
- Graph partition
- MySQL Partition
- split partition
- MySQL partition
- Database Partition
- oracle partition
- linux partition
- exchange partition
- hive partition
- GetMessage和PeekMessage
- Cocos2d-x 3.0 红孩儿私家必修 - 第一章 初识Cocos2d-x 3.0工程
- Android 处理横竖屏切换事件
- 怕丢弃的父亲
- EBS - Data Dictionary (Schema/Module)
- partition.with_index
- 在堆溢出时保存快照:-XX:+HeapDumpOnOutOfMemoryError
- SQL 转义字符
- hdoj1107武林
- Sapphire 手机FTP文件上传下载控件Sapphire FTP Utility介绍
- xpressive是boost的正则表达式库
- hdu 4115 2-sat
- Malware online scanners
- add Admob with Cocos2d-x on iOS