initialization

Initializing Java object instances containing an array of objects

The following code is correct: public Sample mOboeSamples[] = { new Sample(1,1), new Sample(1,2) }; public Sample mGuitarSamples[] = { new Sample(1,1), new Sample(1,2) }; public SampleSet mSampleSet[] = { new SampleSet( "oboe", mOboeSamples ), new SampleSet( "guitar", mGuitarSamples) }; but I'd like to write ...

C++ static const and initialization (is there a fiasco)

Hi all, I am returning to C++ after a long absence and I am stumbling a little over my understanding of the fairly well known static initialization problem. Let's say I have a simple class Vector2 as given below (note that I am aware that x and y should be private with getters and setters, these have just been omitted for brevity): cl...

iPhone initializing a UIViewController with additional data

Hi guys, I have a custom UIViewController subclass, which gets pushed on a UINavigationController stack. I want to add some data of my own at the time of initialization/pushing. Should I a) write a custom init method with my data as argument, like this? MyCustomViewControllerSubclass.m: -(id) initWithNibName: bundle: myCustomData: {...

Rails: Initializing attributes that are dependent on one another

I have the following classes in my ActiveRecord model: def Property < ActiveRecord::Base # attribute: value_type (can hold values like :integer, :string) end def PropertyValue < ActiveRecord::Base belongs_to property # attribute: string_value # attribute: integer_value end A PropertyValue object is intended to hold only a str...

Spring bean initialized on web app starts up

This is probably due to my ignorance of the Spring framewok but i am building a JSF+Facelets+Spring web app, i have a bean that whose init method i want to get called at the time the application is started. My problem is getting the bean initialized. I can reference the bean on a page, and when I go to the page, the bean is initialized,...

How can I copy a git repository into a new svn repostory?

I have some code that I want to put into an svn repository for a client after doing some work on it in git, is there any way to initialize a svn repository using a git repository's history? I have initialized git repositories from svn repositories, and regularly commit between existing svn and git repositories, but I don't know how to...

What are the sins of crosses initialization?

Consider following code: #include <iostream> using namespace std; int main() { int x, y, i; cin >> x >> y >> i; switch(i) { case 1: // int r = x + y; -- OK int r = 1; // Failed to Compile cout << r; break; case 2: r = x - y; cout << r; ...

(function() {})() declaring/initializing javascript function

Possible Duplicate: JavaScript: Why the anonymous function wrapper? Hi Guys, I would like to ask you what is the reason of wrapping everything in (function() { document.write("Hello World!"); })(); function ? cheers ...

Python - Initializing Multiple Lists/Line

This is terribly ugly: psData = [] nsData = [] msData = [] ckData = [] mAData = [] RData = [] pData = [] Is there a way to declare these variables on a single line? ...

Array variable initialization error in Java

Hello I am trying to write a Java program that reads an input file consisting of URLs, extracts tokens from these, and keeps track of how many times each token appears in the file. I've written the following code: import java.io.*; import java.net.*; public class Main { static class Tokens { String name; int c...

iphone dev: UIImageview subclass interface builder - how to call custom initializer

hi. I messing with iphone developement. I have a uiimageview subclass that I want to use to detect touches. I have sucessfully added to interfacebuilder and I can detect a touch in my UIImageview subclass within my application so all is good on that front. however my UIImageView subclass has a custom initializer which is not called w...

Instance initialization strategy in c#

For a class instance to work properly, some fields should be properly initialized, what's your strategy to initialize these field, what should be given through constructor, what should be given through property? My confusion is that, if the constructor requires a long parameter list, it's hard to use, if through properties, i tend to fo...

Static Initialization Blocks.

As far as I understood the "static initialization block" is used to set values of static field if it cannot be done in one line. But I do not understand why we need a special block for that. For example we declare a field as static (without a value assignment). And then write several lines of the code which generate and assign a value to...

How to execute assembly code when application starts

I know this question is similar to several previous ones, but I can't find an exact answer. I have an application framework that, amongst other things, handles unhandled errors. At the moment I require that the host application calls a Register method in the application's Main method to register the handlers and various sub-systems. I...

When -exactly- does the Rails3 application get initialized?

I've been fighting left and right with rails 3 and bundler. There are a few gems out there that don't work properly if the rails application hasn't been loaded yet. factory_girl and shoulda are both examples, even on the rails3 branch. Taking shoulda as an example, when trying to run rake test:units I get the following error: DEPRECATION...

When initializing in C# constructors what's better: initializer lists or assignment?

Class A uses an initializer list to set the member to the paramter value, while Class B uses assignment within the constructor's body. Can anyone give any reason to prefer one over the other as long as I'm consistent? class A { String _filename; A(String filename) : _filename(filename) { } } class B { String _f...

WinForms Load Event / Static Initialization Strangeness

Background I'm troubleshooting an WinForms 2.0 program that's already been burned to CD for distribution to an internet-challenged target audience. Some users are experiencing a fatal error that I can reproduce locally. Reproducing the Error I get the fatal error when I log into my Vista box using a standard user that I just created,...

Variable might not have been initialized error

When i try to compile this: public static Rand searchCount (int[] x) { int a ; int b ; ... for (int l= 0; l<x.length; l++) { if (x[l] == 0) a++ ; else if (x[l] == 1) b++ ; } ... } I get these errors: Rand.java:72: variable a might not have been initialized ...

C# - closures over class fields inside an initializer?

Consider the following code: using System; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var square = new Square(4); Console.WriteLine(square.Calculate()); } } class MathOp { protected MathOp(Func<int> calc) { _calc ...

Asterisk sometimes on variable type, sometimes on variable name. Why?

In Objective-C, I've seen, for example: UIPickerView *tweetPicker and UIPickerView* tweetPicker What does the asterisk mean (I know, the first part is a dupe...) and why does it go on different parts of the deceleration in different contexts? ...