Skip to content

Instantly share code, notes, and snippets.

@randallreedjr
Created March 6, 2016 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randallreedjr/476531e9533d69e89199 to your computer and use it in GitHub Desktop.
Save randallreedjr/476531e9533d69e89199 to your computer and use it in GitHub Desktop.
Second code sample for post Ruby Abstraction in Loops
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