Skip to content

Instantly share code, notes, and snippets.

@m0n4d1
Created March 1, 2019 22:56
Show Gist options
  • Save m0n4d1/20abc3f97743580ea82d1adde27da759 to your computer and use it in GitHub Desktop.
Save m0n4d1/20abc3f97743580ea82d1adde27da759 to your computer and use it in GitHub Desktop.
ruby Iteration insights
my_array = [1,2,3]
#Loop iteration
#---------------------
for item in my_array do
p item
end
#---------------------
#Hard-coded iteration
#---------------------
def do_block(item)
p item
end
item = my_array[0]
do_block(item)
item = my_array[1]
do_block(item)
item = my_array[2]
do_block(item)
#---------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment