Created
March 6, 2016 22:33
-
-
Save randallreedjr/2ce43634b33c0cfa5573 to your computer and use it in GitHub Desktop.
Third 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] | |
squares = [] | |
array.each do |element| | |
squares << element ** 2 | |
end | |
squares | |
# => [1,4,9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment