Examples of using Initializers in English and their translations into Chinese
{-}
-
Political
-
Ecclesiastic
-
Programming
Static Data Member Initializers.
Initializers can also reject objects.
Variable declarations without initializers.
Using object initializers, we could do it a bit shorter:.
We can have multiple static initializers in a class.
Initializers are used to initialize the network's variables before training.
A var declaration can include initializers, one per variable.
Any remaining initializers are left to initialize the next array element:.
The subclass in this figure has two designated initializers and one convenience initializer.
Initializers are controllers that can modify objects before they are created.
UTF16View has no public initializers and few mutating functions.
Initializers are now able to access self and can modify its properties, call its instance methods, and so on.
Local variable declarations typically have initializers, or are initialized immediately after declaration.
Initializers set up the starting state for each particle that is created, initializing the fields within each particle.
Single String property called name and provides two initializers for creating Food instances:.
For static fields, variable initializers correspond to assignment statements that are executed when the class is loaded.
Single String property called name and provides two initializers for creating Food instances:.
Initializers only set up starting properties of each particle as it is created, after which they have no effect on each particle.
Of course, it's limited; you can't overload instance initializers, so you can have only one of these constructors.
Enum members have the type of their containingenum type(except within other enum member initializers: see§14.2).
The convenience initializer must call one of the two designated initializers, because it can only call another initializer from the same class.
Both initializers convert their single argument into a value in the Celsius scale and store this value in a property called temperatureInCelsius.
The Food class introduces a single String property called name andprovides two initializers for creating Food instances:.
If your subclass doesn't define any designated initializers, it automatically inherits all of its superclass designated initializers.
This example defines a hierarchy of three classes called Food, RecipeIngredient, and ShoppingListItem,and demonstrates how their initializers interact.
Infered types will be restricted to local variables with initializers, indexes in the enhanced for-loop, and locals declared in a traditional for-loop;
It introduces an Int property called quantity(in addition to the name property it inherits from Food)and defines two initializers for creating RecipeIngredient instances:.
Other than this circularity restriction, enum member initializers may freely refer to other enum member initializers, regardless of their textual position.
Between consecutive members(or initializers) of a class: fields, constructors, methods, nested classes, static initializers, instance initializers.
This treatment would be restricted to local variables with initializers, indexes in the enhanced for-loop, and locals declared in a traditional for-loop;