Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

init
array
dlang
communitycreator

What is the init property of an array?

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The init property of an array returns an array literal, with each element of the literal being the .init property of the array element.

Syntax

array.init

Return value

It returns an array literal, with each element of the literal initialized.

Example

// import std.stdio
import std.stdio;
// main method
void main(string[] args) {
// create an array
string[3] names;
// add values
names[0] = "Theodore";
names[1] = "John";
names[2] = "Jane";
// print the length of the array
writeln(names.init);
}
Get the init of array elements

Explanation

  • Line 2: We import the std library.
  • Line 5: We create the main method.
  • Lines 9–11: We assign the values to the elements of the array.
  • Line 14: We print the init of the array elements to the console.

RELATED TAGS

init
array
dlang
communitycreator

CONTRIBUTOR

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring