I need some help with the following:
- in a method create a new array based on the input parameter
- return an array from that method
- output the contents of the array the most elegantly?
mycontroller.rb
def test(num)
#take the number and create a new array and return the array with the numbers.
#example input: 5
#output: array with 5 indexes and values of [1,2,3,4,5]
end
# output the contents of the array
i = 0
while i < 5
puts test(i)
end
Thanks!
You can use ruby ranges for this:
To print an array use the
inspectmethod, i.e.