Created
March 6, 2016 22:30
-
-
Save randallreedjr/476531e9533d69e89199 to your computer and use it in GitHub Desktop.
Second code sample for post Ruby Abstraction in Loops
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
array = [1,2,3] | |
current_index = 0 | |
squares = [] | |
while current_index < array.size | |
squares << array[current_index] ** 2 | |
current_index += 1 | |
end | |
squares | |
# => [1,4,9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment