Today marks the end of a 365 day journey of writing one Ruby programming tip everyday. It has been a long journey to consider new and interesting content in the realm of a Ruby and Rails programmer. I have learned so much and I am very happy to share this content with the world.

For today’s final tip, in the 365 days of Ruby series, let’s look at how the each_slice() method does what it can to arrays. We can iterate over collections and grab the modulus of three and return a result when that happens.

[1,2,3,4,5,6,7,8,9,10].each_with_index do |num, idx|
  puts "#{num}"
  if ((idx + 1) % 3 == 0)
    puts "end of line" 

#=> 1
#=> 2
#=> 3
#=> end of line
#=> 4
#=> 5
#=> 6
#=> end of line
#=> 7
#=> 8
#=> 9
#=> end of line
#=> 10
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Where to go from here? Soon I will edit, revise and compile these Ruby tips in a cohesive work. The updated body of work will be available for purchase in an easy to read format with bonuses on how to utilize these tips further. My hope is programmers of all levels will appreciate, find humor, and enjoy the value these tips will have on your craft. PARTY!



    • Johan AndrĂ© March 2, 2014
    • Reply

    Good job man!
    I discovered the “series” some times ago and theres alot of good stuff in here! 🙂
    Looking forward to the book, will buy it for sure!

    • Stephen Giles March 2, 2014
    • Reply

    Is there a way to view these in order from the start without starting at #365 and working backwards?

      • BrettU March 2, 2014
      • Reply

      Not currently. Maybe I will create a filter for these one day.

Leave a Reply

Screen Shot 2013-12-08 at 9.49.35 PM

I have helped a dozen companies build and optimize their engineering teams to deliver great products.

Let’s work together and I can align your business needs with your technology initiatives.