initialization Questions
9
Solved
In certain other languages (AS3 for example), it has been noted that initializing a new array is faster if done like this var foo = [] rather than var foo = new Array() for reasons of object creati...
Handmade asked 11/5, 2011 at 15:28
2
Solved
Given this powershell code:
$drivers = New-Object 'System.Collections.Generic.Dictionary[String,String]'
$drivers.Add("nitrous","vx")
$drivers.Add("directx","vd")
$drivers.Add("openGL","vo")
Is ...
Conveyance asked 20/7, 2011 at 16:37
5
Solved
I want to generate a sequence of numbers in Go but I can't find any built-in functions for this.
Basically I want the equivalent of PHP's range function in Golang:
array range ( mixed $start , mi...
Monazite asked 5/10, 2016 at 7:37
12
Solved
I just got into a new company and much of the code base uses initialization methods instead of constructors.
struct MyFancyClass : theUberClass
{
MyFancyClass();
~MyFancyClass();
resultType ini...
Lathrop asked 24/9, 2010 at 12:4
3
Solved
I am trying to initialise an std::vector<std::unique_ptr<std::string>> in a way that is equivalent to an example from Bjarne Stroustrup's C++11 FAQ:
using namespace std;
vector<uniq...
Steam asked 8/3, 2012 at 13:18
15
Solved
Is it possible to create an empty array without specifying the size?
For example, I created:
String[] a = new String[5];
Can we create the above string array without the size?
Isolate asked 4/1, 2012 at 12:49
5
Solved
Consider the following struct initialization:
#include<stdio.h>
struct bar {
int b;
int a;
int r;
};
struct foo {
struct bar bar;
};
int main(int argc, char **argv) {
struct bar b = ...
Doloritas asked 1/12, 2016 at 21:28
6
Solved
I've seen how to define a class as being a singleton (how to create a singleton in Ruby):
require 'singleton'
class Example
include Singleton
end
But what if I want to pass some parameters to #...
Holtz asked 10/3, 2011 at 12:8
13
Solved
So, I have the following:
std::vector< std::vector <int> > fog;
and I am initializing it very naively like:
for(int i=0; i<A_NUMBER; i++)
{
std::vector <int> fogRow;
for(int...
Kipton asked 15/7, 2013 at 20:21
14
I'm having issue for writing custom init for subclass of UIViewController, basically I want to pass the dependency through the init method for viewController rather than setting property directly l...
Evident asked 10/2, 2016 at 12:31
4
Solved
I'm taking a look at how the model system in django works and I noticed something that I don't understand.
I know that you create an empty __init__.py file to specify that the current directory is...
Nasa asked 23/9, 2008 at 4:41
3
If all objects have at least one constructor be it default c'tor defined by the compiler or user defined then how can objects be uninitialized.
Hodgson asked 26/9, 2017 at 13:19
11
Solved
I am initializing an array like this:
public class Array {
int data[] = new int[10];
/** Creates a new instance of Array */
public Array() {
data[10] = {10,20,30,40,50,60,71,80,90,91};
}
}...
Pathetic asked 21/12, 2009 at 3:59
8
Solved
This should work according to another stack overflow post but its not:
Dim arrWsNames As String() = {"Value1", "Value2"}
Can anyone let me know what is wrong?
Monoploid asked 14/10, 2013 at 20:54
7
Solved
I'm currently in charge of finding all bad practices in our code base and to convince my colleagues to fix the offending code. During my spelunking, I noticed that many people here use the followin...
Rigadoon asked 19/3, 2012 at 9:32
7
Solved
Our code involves a POD (Plain Old Datastructure) struct (it is a basic c++ struct that has other structs and POD variables in it that needs to get initialized in the beginning.)
Based one what I...
Brazilein asked 6/5, 2011 at 16:39
6
Solved
I'm curious about the underlying implementation of static variables within a function.
If I declare a static variable of a fundamental type (char, int, double, etc.), and give it an initial value,...
Nauseate asked 22/5, 2009 at 15:20
5
Solved
If I initialize a std::array as follows, the compiler gives me a warning about missing braces
std::array<int, 4> a = {1, 2, 3, 4};
This fixes the problem:
std::array<int, 4> a = {{...
Amphicoelous asked 6/1, 2013 at 1:10
8
Solved
Given the following code
interface IPerson {
firstName: string;
lastName: string;
}
var persons: { [id: string]: IPerson; } = {
"p1": { firstName: "F1", lastName: "L1" },
"p2": { firstName: "...
Nedi asked 8/4, 2013 at 10:56
7
I know in C that I can do the following.
int test[5] = {1, 2, 3, 4, 5};
Now this is only legal when declaring the array. However I was wondering why this is not legal to do later? But then later...
Kathiekathleen asked 5/3, 2012 at 15:2
3
Solved
Let's say I need to write incoming data into a dataset on the cloud.
When, where and if I will need the dataset in my code, depends on the data coming in.
I only want to get a reference to the data...
Tedesco asked 16/9, 2017 at 0:50
4
Solved
I would like to call an asynchronous function outside the lambda handler with by the following code:
var client;
(async () => {
var result = await initSecrets("MyWebApi");
var secret = JSON.p...
Skillet asked 18/3, 2019 at 18:36
7
Solved
I'm looking for a compact syntax for instantiating a collection and adding a few items to it. I currently use this syntax:
Collection<String> collection =
new ArrayList<String>(Array...
Lexis asked 22/9, 2010 at 13:2
5
Solved
How do I initialize std::array<T, n> if T is not default constructible?
I know it's possible to initialize it like that:
T t{args};
std::array<T, 5> a{t, t, t, t, t};
But n for me i...
Levantine asked 28/8, 2013 at 19:57
1
Solved
If your question was closed as a duplicate of this, it is because you had a code sample including something along the lines of either:
class Example:
def __int__(self, parameter):
self.attribute ...
Mesomorph asked 2/6, 2022 at 21:0
© 2022 - 2024 — McMap. All rights reserved.