11,826 questions
9
votes
4
answers
73k
views
Initialize a calendar in a constructor
If I do this:
new Estimacao("Aarão","Affenpinscher","Abóbora",new GregorianCalendar(1999,7,26),0),
Everything works as as expected.
But if i do this:
new Estimacao("Aarão","Affenpinscher","Abóbora",...
5
votes
3
answers
5k
views
Initialise Cython Memoryview efficiently
I'm currently setting my MemoryViews in my Cython pyx file as follows:
@cython.boundscheck(False)
cdef int[:] fill_memview():
# This happens inside a big loop so needs to be fast
cdef int[:] ...
27
votes
4
answers
26k
views
Lazy instantiation in Objective-C
I understand that all properties start out as nil in Objective-C and that sending a message to nil does nothing, therefore you must initialize using [[Class alloc] init]; before sending a message to a ...
2
votes
1
answer
69
views
String initialization without assignment and braces?
I have a question about following code segment which presents in "A Tour of C++, Third Edition, pg:111"
string s "Hello ";
Is this a typo or is there an initialization syntax like ...
0
votes
0
answers
32
views
Kotlin variable vs field initialization semantics
Let's consider the following Koltin code:
val a: Int = 1
class A {
val a: Int = a // error here: a is not initialized
fun f() {
val a = a // this is fine, a on the right-hand side ...
642
votes
5
answers
333k
views
What are the advantages of list initialization (using curly braces)?
MyClass a1 {a}; // clearer and less error-prone than the other three
MyClass a2 = {a};
MyClass a3 = a;
MyClass a4(a);
Why?
3
votes
6
answers
8k
views
How to check if allocated memory is initialized or not
I am exposed to the pointer int* i, of which I only know its memory is allocated but am not sure it has been initialized to some integer or not.
If I try to deference it, what would happen? In other ...
0
votes
2
answers
49
views
Creating class instances and attributes inside new method [closed]
Assume I want to create a class instance only if certain calculation gives positive number, otherwise, return None.
I can create a staticmethod and just use if - else inside... But it is not intuitive ...
6
votes
8
answers
229
views
Single-value object initializer
This might be lame, but here:
public interface Interface<T>
{
T Value { get; }
}
public class InterfaceProxy<T> : Interface<T>
{
public T Value { get; set; }
}
public class ...
2
votes
1
answer
100
views
Program with std::variant works in msvc but not in gcc
I wrote the following program that works with msvc c++17 but rejected by gcc and clang. I want to know which compiler is right here.
Demo.
#include <variant>
struct C
{
std::variant<bool&...
0
votes
2
answers
12k
views
Firebase Android - Skipping initialization
I am currently implementing an Android app, which uses Firebase Cloud Messaging.
I've implemented everything according to the tutorial on the Firebase page.
However, whenever I try to run my app it ...
0
votes
1
answer
59
views
How to start a screen session from entrypoint shell script, and make it persist? [closed]
I am starting a screen session in my entrypoint shell script in docker, then log the output of screen -list to a file.
#!/bin/bash
screen -S my_screen -dm bash -c 'cd project && npm run start'...
28
votes
7
answers
29k
views
What is the difference between initialization and assignment?
What is the difference between initialization and assignment?
I was confused by the following statement:
C++ provides another way of initializing member variables that allows us to initialize member ...
0
votes
1
answer
47
views
VBA: initializing a string array
New to VBA, and utterly frustrated. Just trying to simple initialize an array of strings.
Dim MyArray() As String
MyArray = Array("A", "B", "C")
Returns Run-time Error 13:...
0
votes
0
answers
53
views
How to initialise one part of a list in the front end before the second part is loaded? (Blazor Server)
I'm experimenting with the ChatGPT API. I want the user prompt to be shown in a message before the GPT answer is loaded, but its refusing to do anything until both are loaded.
My Initial Code was this ...