To .Each All Elements

If you ever need to iterate
through a short or a long unwieldy array
I know of an easy way

Just type that list aka array
May it be [“cap”, “panama”, “sombrero”, “fez”]
or even [ 3,5,6, 7,8]
there is nothing that .each can’t take

within .each that is this named bit of code called block
where your statements are organized and snugly locked
you start with “do” and only with an”end” it’ll stop

In the block you represent an array element inside pipes
these are bizarre characters, Dracula-teeth alike | |
name inside it any argument for the magic to start

Say you want to print all elements of [“Kate”, “Nisha”, “Gus”, “Chris”]
.each loops through this array awesome_fantastic_team
printing on the console these beautiful strings

To each its own you may say
But if you want to sound Blake-cool, speak: ” to .each all elements of a given array”
’cause this is the Ruby way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s