Ruby Programming – 11 – counter – index – .each do

Ruby programming tutorial on counter, index, .each do. Ruby programming tutorial.



Twitter ►

YouTube ►

Facebook ►

SoundCloud ►

★☆★ NOTES ★☆★


Boundless says:

you missed butterscotch. It’s the best candy in the world.

Omar Suriel says:

I loved all your other videos so far. But in this video seems like you’re just doing stuff and not really explaining what you are doing or why.

Klee - wai :3 says:


Jeremy Wehrly says:

I researched and found that the do statement just executes whatever you are trying to call. Also I was able to learn that the vertical lines is just where you input the parameters. for example do|candy, index| will execute the candy method and it will index the candy method. Hopefully this is right.

Trell CEO says:

How do you know when to start classes and instances? Are you going to do videos on Rails framework?

Liu Chang says:

hi Jacob! ive some problem with install ruby on my mac.i downloaded the newest ruby on my mac 10.9
and i used commond:

ruby -v

shows me

ruby 2.00.p274

which ruby


then i try to drag a .rb file on Terminal it showed me:
-bash: /users/jimmy/documents/ruby-1.rb permission denied 

what should i do T____T?

brian kimbrough says:

my code worked the first time becaus i uesd auto spell check.

Aaron Blandon says:

You don’t need to keep dragging files into the terminal. Use command history and hit the up arrow, then Enter [Return].

Tim Parrott says:

noticed with the _with_index the count always starts with zero. Normally most counts would start with one. How is that handled?

Yvigny Goncharov says:

Needs a “.capitalize” on the list items 😀

That all LC stuff just looks wrong.

Jorge Ramirez says:

I created a code that count the items and add this is “the 1st is: First line” “the 2st is: Second line” and “the 3st is: third line”

But the funny part is that I add a counter inside the function, but I fear first that this counter would change the main index function (grab the first item in the Array) but it didnt which was a great surprise !

Here is the code:

#!/usr/bin/env ruby

array_test = [“First Line”, “Second Line” , “Third Line”]

array_test.each_with_index do |item,index|
puts ” The #{index}st is: #{item}”



Is fun to try stuff :p

David thegreat says:

you are truly a great fellow cheers …

Jorge Ramirez says:

Would be nice that you explain what “each” does, what would be that it takes each of the items in the Array starting in 0

But why we need to add the “|item|”? to create a variable? thats the reason we add later the word “index” after items so we have a variable called index? or the word index knows that he is an automatic counter?

olofis pg says:

cant find the straight line botton

Noal Tessman says:

Why can you use print here and not chomp? doesn’t chomp keep it all on the same line?

Joshua Fullmetal says:

Just wanted to say thanks for this series. I’m coming from C# and am finding I am falling in love with this language. Can you recommend any good Ruby GUI frameworks for making forms and what not? I’ve been spoiled by Visual Studio, it was really the only thing that was keeping me to C#.


ambi kaur says:

HI Jacob.. Thank You thank you .. Thanks a ton.. i just love ur videos and never get bored watching them .. you are a Star!!

Rico Ferdian Alexander says:

Thanks, this 11th video is very great..

kevin jones says:

Thnx a million for the great work you have done with your instructions.  But, I have a question. Is the editor bundled with the IDE?  I have studied your videos, but I haven’t downloaded the IDE as of yet.

Eric Reiss says:

Very helpful! I was stuck and you helped me get unstuck.

Tim Parrott says:

figured it out by adding within the {index} variable {index +1} in the line:
puts “#{index +1} ….

Rajeev Kumar says:

Hi Jacod..I got opportunity to work on ruby +watir+cucumber as a Automation Engineer.Actually I am new to this technology.can you please suggest me how to ahead or which is the best way to learn this technology.Thanks!

kelvin chege says:

called a pipe |

MuscleBoi1901 says:

I know this video was from ages ago but would be nice if you explained what the vertical line | meant or what .each does…

Omar Suriel says:

This is the first video that really made no sense to me. it seems like you didn’t really explain why you did the thins you do. But i went on amazon and bought your book. I will start reading it right now hopefully it help me figure out things better. thanks for your videos anyways!!

Алексей Александрович says:

hi, Jacob.
can u tell please how can i start index not from 0, but 1? And if that is possible, how can i use cyrrilic symbols? 
sry my bad english

Kewendi says:

Can you please explain more what the each do command means and also why you have to use the pipes and what this line means favorite_candy.each do |item|

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!