You can use ruby ranges for this:
list = (1..num).to_a
To print an array use the inspect
method, i.e.
puts list.inspect
3
solved Send in a number and return an array in Ruby [closed]
You can use ruby ranges for this:
list = (1..num).to_a
To print an array use the inspect
method, i.e.
puts list.inspect
3
solved Send in a number and return an array in Ruby [closed]