Ruby slice big array into equal parts

By using each_slice we can convert single dimension array in to multi dimention array  foo.each_slice(3).to_a #=> [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"], ["10"]] 

Comments

Popular posts from this blog

Rails Memcache issues

Enabling password authentication for new ec2 box | ssh, ssh config, EC2 setup, new user in EC2, PasswordAuthentication

Ruby on Rails 3.x Skip callback and validation and reset Callback | Ruby on Rails, Skip callback, validation, reset Callback