Created
March 1, 2019 22:56
-
-
Save m0n4d1/20abc3f97743580ea82d1adde27da759 to your computer and use it in GitHub Desktop.
ruby Iteration insights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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