Difficulty:
Elementary
Elementary
Tags:
enumerables
enumerables
Instructions:
How would you create an array that contains the squares of all elements in a range?
How would you create an array that contains the squares of all elements in a range?
Problem and Solution:
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
# Solution to 'Map' on rubeque.com | |
# by jakthegr8 | |
# http://www.rubeque.com/problems/map | |
assert_equal [1, 4, 9, 16], (1..4).map { |ele| ele * ele } |