Ruby Array New Syntax

[Solved] Ruby Array New Syntax | Haskell - Code Explorer | yomemimo.com
Question : Ruby Array.new syntax

Answered by : codebaron

Array.new( number of indices, value of the indices ) { optional block for value of indices }
ary = Array.new #=> []
Array.new(3) #=> [nil, nil, nil]
Array.new(3, true) #=> [true, true, true]
Array.new(3) { Hash.new } #=> [ {}, {}, {} ]

Source : https://ruby-doc.org/core-2.4.1/Array.html | Last Update : Fri, 14 Feb 20

Question : how to make a new array ruby

Answered by : travis-m

my_array = []
# OR
my_array = [1, 2, 3]
# OR
my_array = Array.new
#OR
(1..10).to_a

Source : | Last Update : Thu, 18 Jun 20

Question : ruby create array

Answered by : christopher-olson

array = Array.new

Source : | Last Update : Wed, 17 Jun 20

Answers related to ruby array new syntax

Code Explorer Popular Question For Haskell