Course Content

Course Content


Use square brackets ([]) to build an array in a Ruby program, and commas to separate the values you want to store. The percent w technique, on the other hand, allows you to bypass the quotations and commas.

Calling the::new method with zero, one, or more than one arguments creates a Ruby array. arrayName = Array. new is the syntax.

  • Making use of the literal constructor. The literal constructor [] can be used to generate a new array. Take a look at the list below:
  • The use of a new keyword. The new function can also be used to build an array using arguments.
  • Making use of a block. Arrays can also be constructed by using new and a block.

Objects are listed, separated by commas, and enclosed in square brackets to form an array. This produces a 5-element Array, or a bag containing 5 items: a string, a number, true, a symbol, and another number. Arrays can hold any type of object.

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere