【发布时间】:2011-12-20 23:47:45
【问题描述】:
我需要以下方面的帮助:
- 在方法中根据输入参数创建一个新数组
- 从该方法返回一个数组
- 最优雅的输出数组的内容?
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
谢谢!
【问题讨论】:
-
如果这不是问题,那么你需要回到小学去了解“问题”的定义是什么。这不是家庭作业。我正在学习 Ruby,需要帮助来理解它。
-
然后问一个问题。您有一个不构成问题的三个不相关要求的列表,而 Stack Overflow 绝对不是为您编写代码。
标签: ruby-on-rails ruby