Top "Initialization" questions

Initialization deals with the task of initializing the contents of your data structure.

Python - Create a list with initial capacity

Code like this often happens: l = [] while foo: #baz l.append(bar) #qux This is really slow if you're about …

python list dictionary initialization
How to set default values in Go structs

There are multiple answers/techniques to the below question: How to set default values to golang structs? How to initialize …

go struct initialization default-value
Why is list initialization (using curly braces) better than the alternatives?

MyClass a1 {a}; // clearer and less error-prone than the other three MyClass a2 = {a}; MyClass a3 = a; MyClass a4(a); …

c++ c++11 syntax initialization list-initialization
Initializing a struct to 0

If I have a struct like this: typedef struct { unsigned char c1; unsigned char c2; } myStruct; What would be the …

c struct initialization
C++ where to initialize static const

I have a class class foo { public: foo(); foo( int ); private: static const string s; }; Where is the best place …

c++ static initialization constants
Initializing C# auto-properties

I'm used to writing classes like this: public class foo { private string mBar = "bar"; public string Bar { get { return mBar; } …

c# initialization automatic-properties
How to initialize an array in one step using Ruby?

I initialize an array this way: array = Array.new array << '1' << '2' << …

ruby arrays initialization
Options for initializing a string array

What options do I have when initializing string[] object?

c# arrays initialization
Cannot instantiate the type List<Product>

I have the following code: List<Product> product = new List<Product>(); The error: Cannot instantiate the …

java list initialization ejb
Default Values and Initialization in Java

Based on my reference, primitive types have default values and Objects are null. I tested a piece of code. public …

java initialization global-variables default-value local-variables