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
0 answers
Ambiguous reference to member 'init(coder:)' when calling super.init(nibName: nibNameOrNil, bundle: nil)
While trying to implement the cocoa pod, BWWalkthrough, into my current project programmatically, I ran into a problem with the init functions/inheritance.
I tried to subclass BWWalkThroughViewController in my own class…

Jonathan Wong
- 460
- 5
- 11
0
votes
1 answer
Seeding fails when initializer is triggered
Lately, I have been using the next initializer in a Rails 5 project:
initializers/initialize_configs.rb
$current_city = Config.first.city
But after a few changes, I had to rails db:migrate and rails db:seed and then, I got this error. Until that…

Juanse Cora
- 755
- 9
- 19
0
votes
0 answers
Missing Initializer In Bitfield Declaration in C
I have a struct defined as:
#pragma pack(push,1)
typedef struct {
uint8_t source_ID;
uint8_t dest_ID;
union {
uint8_t node_ID;
struct {
unsigned int dest : 4;
unsigned int source : 4;
…

cDreamer
- 385
- 5
- 18
0
votes
2 answers
Property Initializer cannot reference non-static field
I thought the new C# 6.0 property initializers like this.
public MyType MyProperty { get; } = new MyType(OtherProperty);
was the equivalent of this
private MyType _myVariable;
public MyType MyProperty { get { return _myVariable ?? _myVariable = new…

Colin Steel
- 1,045
- 1
- 11
- 24
0
votes
1 answer
override initializer from generic class
open class CheckItem: DataTableItem {
public override init(_ data: T, getter: @escaping (T) -> U) {
super.init(data, getter: getter)
}
}
open class DataTableItem

Andrew
- 3
- 2
0
votes
1 answer
OO Javascript: array not getting initialized
I'm programming a library (in ES6 Javascript) with three classes: opening hours, book, books. And the "main" class library (which consists of the previous classes).
The console error I'm getting is the following: Uncaught TypeError: Cannot set…
0
votes
1 answer
adding custom font for tableview cells
I wanted to add a custom font to my app so I added it here as I did for other labels.
let question = QuestionController.questionsList[questionIndex]
cell.nameLabel.text = question.answers?[indexPath.row]
cell.nameLabel.numberOfLines =…

sheishistoric
- 85
- 1
- 9
0
votes
0 answers
c# property with private setter: why do new [..class..] .. { private property initializer = ... } work?
I have this example code:
static class Program
{
var x = new TestClass { TestList = { "Peter", "Paul" } };
// x.TestList is loaded with 3 string elements: "Hi there", "Peter", "Paul"
}
public class TestClass
{
public List…

Troncho
- 81
- 7
0
votes
0 answers
Compilation error failable initializer of struct
I have to initialise values by reading from JSON file hence was writing failable initiazer. Please review following code and provide suggestions
struct ViewModel {
var cards : EmployeeData
init?() {
if let path =…

Hrishikesh Devhare
- 894
- 10
- 9
0
votes
1 answer
Swift Playground - Use of unimplemented initializer 'init(size:)' for class
I have a class Branch and I have implemented my custom initializer for it. I got an error stating that I have not implemented the init?(coder aDecoder) initializer, which I implemented after that. I am still getting an error saying
Fatal error: Use…

Rimil Dey
- 827
- 2
- 13
- 33
0
votes
1 answer
How to reset a variable in tensorflow?
I want to execute a graph, change the value of a single variable, and then execute the graph again with the change absorbed by any downstream variables. As an example,
A = tf.distributions.Normal(0.0, 1.0)
B = tf.distributions.Normal(0.0, 1.0)
a =…

jdowner
- 718
- 1
- 8
- 21
0
votes
0 answers
Tensorflow use trained model to make predictions initialization error
I've trained a model on some data (just a simple classification task). After, I wish to use this same model to run some predictions via a separate function make_prediction().
So currently my main file is simply something like…

tryingtolearn
- 2,528
- 7
- 26
- 45
0
votes
1 answer
About xavier_initializer in tensorflow
I see the following explanation of xavier_initializer(). It says var(wi) = 1/Navg which take the number of input neurons during practical…

user1424739
- 11,937
- 17
- 63
- 152
0
votes
2 answers
Get list of attributes required to initialize an object of a class
In Python, Is there a way to get list of attributes required to initialize an object of a class?
For e.g. I have below class:
class MyClass:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
And I would like to get,
['a',…

Vivek Harikrishnan
- 866
- 5
- 19
0
votes
1 answer
Rspec on lib + initializer
I'm trying to test a lib I've created. It auto load with an initializer.
Here is what I have
# config/initializer/my_lib.rb
MyLib.configure do |config|
config.salt = Rails.application.secrets.encrypted_salt
config.secret =…

brcebn
- 1,571
- 1
- 23
- 46