Top "Object-initializers" questions

Object initializers let you assign values to any accessible fields or properties of an object at creation time without having to invoke a constructor followed by lines of assignment statements.

What should my Objective-C singleton look like?

My singleton accessor method is usually some variant of: static MyClass *gInstance = NULL; + (MyClass *)instance { @synchronized(self) { if (gInstance == NULL) …

objective-c design-patterns singleton object-initializers
Initial capacity of collection types, e.g. Dictionary, List

Certain collection types in .Net have an optional "Initial Capacity" constructor parameter. For example: Dictionary<string, string> something = …

c# .net memory-management collections object-initializers
How to reinitialize an array in C (not C++)?

How can I reinitialize an array in C? Should I define it through a pointer: int *data[], or can I …

c arrays initialization object-initializers
Best practice to implement a failable initializer in Swift

With the following code I try to define a simple model class and it's failable initializer, which takes a (json-) …

swift object-initializers
Constructor vs Object Initializer Precedence in C#

I've been learning the object initializer in C# recently, but now I'm wondering how it works when it conflicts with …

c# constructor object-initializers
Object initialization syntax

I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3. I.…

syntax f# object-initializers
Use object initializer - Resharper suggestion

I use ReSharper everyday, and today I asked myself why ReSharper suggests "Use object initializer" when I do this : MyClass …

c# optimization resharper object-initializers
Array of dynamic | ExpandoObject | with a compressed initialize syntax

Im trying to use DynamicObject in c#, and I needed an array of dynamic: var d = new dynamic[]; which works …

c# dynamic object-initializers
Objective-C Multiple Initialisers

I have a simple question about creating multiple initialisers within an objective-c class. Basically I have a class that represents …

objective-c initialization object-initializers
Nested object initializer syntax

Resharper has just suggested the following refactoring to me: // Constructor initializes InitializedProperty but // the UninitializedSubproperty is uninitialized. var myInstance = new …

c# specifications object-initializers