Skip to main content

All Questions

3 votes
1 answer
113 views

PHP variable as reference

I'm confused about the concept of variable in PHP. As far as I know, a variable in PHP has a name ($p) and a value ('Carlo'). $p has an associated entry in symbol table, such an entry actually points ...
CarloC's user avatar
  • 313
0 votes
0 answers
27 views

Referring to the variable being assigned to on the right side of the assignment operator

Sometimes it may be necessary (yes, likely against best practices) to deal with nested objects, such as lists, which can require multi-level indexation. I am curious of the following: 1. In Python, is ...
cherryPopsicle's user avatar
4 votes
5 answers
303 views

Why does "setf" not work when using "let"?

The behavior of setf when combined with let is confusing to me. Here, setf isn't changing the second value of my list. (defun to-temp-field (lst) (let ((old-value (nth 2 lst)) (new-value '...
Antonio Solana's user avatar
0 votes
2 answers
44 views

Why are the results different depending on how to assign?

When I tried to reverse the Linked list, I noticed that the results varied depending on how I did the assignments. Why does it happen as bellow? class ListNode: def __init__(self, val=0, next: ...
kama-meshi's user avatar
0 votes
1 answer
21 views

Error with referencing a variable before assignment python

I have a for loop as part of a larger function: for table in tables_list: if table["file"] == file: table_name = table["table_name"] break log.info(f"table: {...
user18466310's user avatar
0 votes
1 answer
357 views

Why can't Kotlin variables assigned from fields change in function?

I'm trying to understand why can't a variable that is assigned from a class field change in a function. Consider this example: class A { private var a: String? = "a" fun hello() { ...
Pedro Romano Barbosa's user avatar
0 votes
2 answers
78 views

C# Generic variable changes if another same type generic changes

I've this class: public class Pair<T, V> { public T A = default; public V B = default; public Pair() { A = default; B = default; } public Pair(T a, V b) ...
ProtoTyPus's user avatar
  • 1,324
1 vote
0 answers
66 views

Is conditionally setting a value by ref correct?

I wanted to know if it is ok to assign a value by ref like this? Merger A = Merger(); // if Condition is true, B references to A, otherwise a different Merger. Merger& B = Condition ? A : Merger()...
M.kazem Akhgary's user avatar
1 vote
1 answer
80 views

Confused with references on pointers in C++

The task is to calculate the output of the following source code without a computer, which I would say is "123 234 678 678" because ref1 is a reference on the value of ptr and in the moment ...
Elliot's user avatar
  • 37
-2 votes
1 answer
1k views

pass by reference or by value in variable assignment of struct, Golang

type temp struct{ val int } variable1 := temp{val:5} // 1 variable2 := &temp{val:6} // 2 In 2, the reference is stored in the variable2. In 1, does the copy operation is taking place? Or ...
Yousuf Ali's user avatar
0 votes
1 answer
452 views

Assign values from list to specific values in a list of dictionaries

I have list of values: list = [value1, value2, value3] And a list of dictionaries where on specific keys I must set the corresponding values: dictionaries = [{"key1":{"key2":{&...
Silver137's user avatar
  • 151
0 votes
1 answer
547 views

Pass by reference vs Pass by assignment? C# vs Python

I am working concurrently in C# and in Python. Is there a difference, in terms of what is being created in memory, between passing a reference type in C#, and passing (by assignment) in Python? It ...
don't train ai on me's user avatar
0 votes
1 answer
210 views

Pass in vs assign const reference in C++

const string& x = functionA(); functionB(x); // depends on x is string or const string& string str = x; We have const ref x: Pass into functionB, so basically we make a copy of the value of x ...
LookIntoEast's user avatar
  • 8,848
0 votes
1 answer
243 views

How can I reference a list initialized in a function? (Python)

The error I'm receiving is local variable 'actions' referenced before assignment. I have a feeling that this is because I am creating the list within the function and then trying to reference it ...
lmurphud's user avatar
0 votes
1 answer
2k views

How to change object value in a loop in Dart

I'm a total newbie in Dart and I've a lot of issues trying to change a member value of an Object inside a loop. I've my object so defined: class Cell { int magicnum, x, y; Cell(this.magicnum); ...
iko's user avatar
  • 77

15 30 50 per page
1
2 3 4 5 6