Questions tagged [initializer]

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

684 questions
0
votes
1 answer

Use static data initializers inline

I have found this section in the cpp_dec_float source file: struct initializer { initializer() { cpp_dec_float::nan(); cpp_dec_float::inf(); …
user1382306
0
votes
2 answers

Rails initializer - what is wrong

This is my first initializer and I do not understand what is wrong. config\initializers\other_server.rb: OtherServer.setup do |config| config.first_server_login = 'qwertyuiop' config.first_server_password =…
Paul
  • 25,812
  • 38
  • 124
  • 247
0
votes
1 answer

initialize() before actionPerformed()

I have a class which implements ActionListener. My actionPerformed() method runs fine. However, there are some things I want to do once before my program starts to run actionPerformed(). I could put a boolean in actionPerformed() and just run it…
Evorlor
  • 7,263
  • 17
  • 70
  • 141
0
votes
0 answers

Timer is not wroking when asynctask() is called inside the timer

I have created a service in which I am running a timer for checking latest change in data to show notification for the change. This same code has run perfectly on my previous apps. @Override public void onCreate() { super.onCreate(); …
Deepti
  • 119
  • 4
  • 12
0
votes
2 answers

initialize a structure in constructor initializer list in C++

// I have a structure typedef struct { uint8_t* data; uint16_t data_ln; } Struc_Data; //a derived type from this struct Struc_Data tx_struct; // i have to initialize this 'tx_struct' in constructor initializer list, i am not getting…
0
votes
2 answers

What are the advantages of C# object/list initializer syntax?

Are there any speed gains when initializing a large amount of static objects? Are there any compile-time or other kinds of advantages? e.g: IList objects = new List { new object(), new object(), new object() }; vs: …
Francisco Aguilera
  • 3,099
  • 6
  • 31
  • 57
0
votes
2 answers

Rails loading initializer classes

In my Rails app, I created an initalizer which responsability is to: Require the service layer of my app Dir[File.expand_path('services/*.rb',\__FILE__)].each { |file| require file } Create those services and inject dependencies in it But now,…
user2854544
  • 851
  • 1
  • 11
  • 23
0
votes
1 answer

java.lang.ExceptionInInitializerError while using SAX XMI parser

I'm trying to parse some XMI tags in here. And though my code is compiled properly. I'm getting following runtime error: java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Uncompilable source code - Erroneous tree type:…
atitpatel
  • 3,104
  • 1
  • 24
  • 34
0
votes
2 answers

Initializing C++ const members with data from function (MPI_comm_size/rank)

I'm creating a class at the moment to wrap some MPI communciation functions, which I construct with a particular MPI communicator. I'd like the class to have the rank and communicator size available as constant member variables. Unfortunately, these…
niallj
  • 3
  • 1
0
votes
2 answers

class member is another class' object

I am a new C++ user... I have a question regarding how to declare a member of a class "classA" that is an object of another class "classB", knowing that "classB" has a constructor that takes a string parameter (in addition to the default…
lounice
  • 39
  • 8
0
votes
1 answer

Invalid object initializer issue in jquery get request?

I want to code an html button with jQuery, when chart button is pressed, will take values from some text inputs, prepare a json of them and will perform a get request including the json with values. $(".chart").click(function(){ var args = {} …
diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
0
votes
1 answer

gcc 4.7.2 error variadic template

I was trying to write a class that could act as a compile-time array, using some TMP and constexpr C++11 magic. The end-goal I was trying to achieve is basically being able to write Type array[Size] = {X, X, X, ..., X}; as Array
JorenHeit
  • 3,877
  • 2
  • 22
  • 28
0
votes
3 answers

How non-static initializer block invoked?

public class A{ { System.out.println("hi i am IIB"); } public A(){ System.out.println("hi i am constructor"); } public static void main(String... args){ A objA=new A(); } }
0
votes
3 answers

How to initialize structure with compiler generated backing fields

Ultra simple question... How does one properly initialize private backing fields on a structure? I get a compiler error: Backing field for automatically implemented property 'Rectangle.Y' must be fully assigned before control is returned to the…
enorl76
  • 2,562
  • 1
  • 25
  • 38
0
votes
1 answer

Twitter integration rails 4 app

I'm attempting to integrate a twitter feed into my Rails 4 application using this gem. I've read the documentation on the github page but I'm running into a problem when trying to use a method in my view. I have the following in an initializer file…
Snarf
  • 2,251
  • 1
  • 15
  • 17