Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters
Questions tagged [initializer]
684 questions
0
votes
2 answers
ASP.NET MVC Initializer doesn't seed Database during Update-Database
The tagged duplicate question uses a custom context, I'm using the default ApplicationDbContext.
I'm confused why data isn't seeded whenever I run Update-Database. I read the other questions with answers but unfortunately they're using a custom…

Jerdine Sabio
- 5,688
- 2
- 11
- 23
0
votes
2 answers
How to retrieve specific value from Collection Initializer Syntax
List studentList = new List() {
new Student() { Id = 1, Name = "John"},
new Student() { Id = 2, Name = "Steve"},
new Student() { Id = 3, Name = "Bill"},
new Student()…

VV Voon
- 133
- 1
- 10
0
votes
2 answers
Paperclip dynamic Proc styles called before object initialized
I have the following paperclip setup. What happens is that I'm using a proc to set the sizes for various styles. However, the proc gets called on new and during the super call. I walked through the debugger and it seems like it processes the :photo…

Bashir
- 21
- 4
0
votes
3 answers
Where and how to specify initializer for an ember engine?
In my application, I have used initializers to inject services to routes, controllers and components. I am trying to use ember engine now. I have shared my application services to my engine, but I need to inject the shared application services to…

Chendraayan
- 75
- 6
0
votes
1 answer
(Swift 4.x+) What are the rules for naming parameters in structs’ initializers?
I have been doing an intense - yet basic apparently - study on structs in these last days and one of the things I cannot understand is why one would ever name parameters in an initializer differently from their original name.
I know that is…

NotationMaster
- 390
- 3
- 17
0
votes
1 answer
JavaFx- initializing scenes in a static way
I want to create a final class, having only static methods- an instance of this class will not be needed- it should be a static container. This class is supposed to have a map field containing created scenes. Now the problem is- method getClass() is…

Embid123
- 467
- 5
- 17
0
votes
1 answer
rspec Object.new does not invoke initialize correctly
module BusinessMath
class Cashflows
include Newton
attr_accessor :cashflows
def initialize(cashflows)
@cashflows = rectify_cashflows(cashflows)
end
private
def rectify_cashflows(cashflows)
cashflows.sort_by!…

Denny Mueller
- 3,505
- 5
- 36
- 67
0
votes
1 answer
array initializer must be an initializer list or string literal c
I am newbie in C. I do not know why I am getting this error and how to fix it?
void FPS_PRINT_ENROLLED(){
int checkNum = 0;
int ID = 0;
int num_Enroll = 0;
num_Enroll = Available_ID();
char strNum[3] = 0;
itoa(num_Enroll, strNum);
…

Sulaiman Alsuhaimi
- 3
- 1
- 2
0
votes
0 answers
Rails 5.2: Requiring ActiveRecord from an initializer
I have in my initializers/my_initializer.rb:
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::NATIVE_DATABASE_TYPES[:string] = {
name: 'varchar',
limit: 191
}
Why does it throw the error: uninitialized constant…

TomDogg
- 3,803
- 5
- 33
- 60
0
votes
1 answer
Initialising in-class member with constructor arguments with round ( ) brackets?
I'm sorry, I haven't programmed C++ in a while, I'd like to refresh my knowledge about what exact rule I'm violating here:
I can do:
int main()
{
int a(5);
}
but cannot do:
struct Foo
{
int a(5); // Error: expected a type specifier / Error:…

Zebrafish
- 11,682
- 3
- 43
- 119
0
votes
0 answers
Using inline C function is impossible in initializer marked via NS_DESIGNATED_INITIALIZER
Say I have a class like this
// DummyObject.h
@interface DummyObject : NSObject
- (instancetype)initWithFoo:(NSString *)foo
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@end
and
//…

NSFish
- 354
- 3
- 10
0
votes
1 answer
Trying to init a struct with self gives error. What is the right way to do it?
I have a network manager struct. I'm trying to initialize it in my main UIViewController but it is failing.
struct NetworkManager {
static var enviroment: NetworkEnviroment = .production
static var apiKey = ""
private let mainApiRouter =…

Kegham K.
- 1,589
- 22
- 40
0
votes
1 answer
How to add a new component when Angular app fails to bootstrap
I have a question about my Angular app, I have an app that gets its initial config data from an API and can bootstrap the app using those config. Here is the ApiConfigService:
export class ApiConfigService {
public initialized: Promise;
…

AlreadyLost
- 767
- 2
- 13
- 28
0
votes
0 answers
Confusing error in initializer list using std::move on unique_pointers
I'm getting this error from this constructor
Severity Code Description Project File Line Suppression State Error
(active) E0289 no instance of constructor "std::unique_ptr<_Ty,
_Dx>::unique_ptr [with _Ty=InputComponent,…

Wesley Richmond
- 11
- 4
0
votes
2 answers
Collection initializer for List not working giving "; expected" compile error. Why?
I am trying to initialize a generic collection List something like this:
List myCustomClassList = new List() {myCustomClassInstance1, myCustomClassInstance2};
I am getting the compile error "; expected". I don't…

richard
- 12,263
- 23
- 95
- 151