A process of setting or re-setting the value stored in the storage location(s) denoted by a variable name.
Questions tagged [variable-assignment]
4336 questions
1
vote
1 answer
why doesn't assignment of int to std::map produce a compiler error
Attempting to assign an int to a string
std::string s = 5;
produces the following compiler error:
error: conversion from ‘int’ to non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string’} requested
however assigning an int to the value…

user438431
- 335
- 4
- 15
1
vote
0 answers
zsh: ${(f)...} doesn't split when used with assignment
It seems that when used in assignments, splitting with ${(f)...} does only work when using ${var=...} (in which case the result is joined again using the first character of $IFS), but not with regular assignments:
% zsh -c 'IFS=:$IFS; printf ">…

philipp2100
- 162
- 1
- 11
1
vote
1 answer
Why am I not able to assign the correct value of boolean result found in the program, to a boolean variable and to check a condition with the result?
I am receiving the value as true when log.d ing the logcat, but when I assign the value to boolean variable it changes to false and also I am not able to do the if condition with the value as it also is showing false. That is I am only able to get…

Sayooj
- 766
- 5
- 23
1
vote
3 answers
How do I set the value of a variable based on another variable?
I am trying to take a scanner input for a variable named site and set another variable, emr, to one of 3 possible values based on what was input for site.
import java.util.Scanner;
public class Program
{
public static void main(String[] args)…

Nick Tagliamonte
- 45
- 4
1
vote
5 answers
Assign value from one associative array of php into another array
I have a variable $params which gets data from the database:
$params = mssql_fetch_array($result)
As far as I know, it is associative array. I want another array $tempParams to hold the value of this array. Can I assign it by using the following…

Syed Tayyab Ali
- 3,643
- 7
- 31
- 36
1
vote
1 answer
I am trying to simplify my multiple array method calls into an if statement or something much more simple based on a condition
I would like to simplify my code and have one array filtering method and then assign the const Alerts based upon the corresponding conditions, instead of 5 array filtering methods. Perhaps an if statement or something of the like would do the…

evan
- 117
- 1
- 10
1
vote
1 answer
Python assignment. Is it possible to distinguish between value and variable?
Sorry, I couldn't think of a better title, naming my use-example of a fuzzy dict wouldn't explain anything.
I want to write a fuzzy dict. The keys would be tuples of integers but retrieval would retrieve the value for that key and for neighbouring…

Haydon Berrow
- 485
- 2
- 6
- 14
1
vote
2 answers
assigning values in a nested list using for loops in python
I need to create a nested list, four levels deep. On the fourth level, I need to systematically assign values. I get an index error, regardless of value assigned, when the fourth level is in the middle of its first loop, as you can see in the…

Luke
- 13
- 3
1
vote
1 answer
Setting JSON field to null using lambda expression
I have a JSON that looks something like this:
"items": [
"something": "",
"something_2": "",
"field_of_interest": {
"blah": [
{
"placeholder": "1",
"category": "random"
…

Ruby
- 413
- 1
- 4
- 16
1
vote
0 answers
Assign values in a for loop using R changing type
I've a matrix of CHARACTER values that I want to be DOUBLE
if get typeof(matrix[index,index]) give me in output CHARACTER
so I need as.double() to swipe it to DOUBLE
I was trying to do it with a for cycle like:
for (el in 4:269){
for (i in 5:66){
…

Diego Rando
- 85
- 8
1
vote
1 answer
When to use let/run/apply/with/also when an object is null?
I want to run a block of code depending if the variable is null or not, but I still don't know when to use let,run...etc.
I want something like this:
myVar?.xxx{
// do something if is not null
} ?: xxx{
// do something is myVar is null
}
What…

ladytoky0
- 588
- 6
- 16
1
vote
1 answer
strange behavior of C++ downcasting on object
i ran the code below to assign parent portion of objet to child object.
but as described inline, c style downcast behaves something unexpected.
what happen there? please refer to the comment below.
struct A {
public:
int i{};
…

kile
- 43
- 3
1
vote
1 answer
Performance of temporary variables vs array element, which is faster, when?
Consider these examples using Python calling several functions returning a number, using an array element:
import numpy as np
my_array = np.zeros(looplength)
for j in range(0,looplength):
temp = my_first_function(j)
my_array[j] = temp
…

Siderius
- 174
- 2
- 14
1
vote
1 answer
Error in assignment to expression with array type
I am trying to code a program that shows the Easter day when the user inputs the year between 1991 and 2099. All are good but when I am trying to run the program, it says there is an error: assignment to expression with array type. How can I fix…
1
vote
2 answers
Variable defined despite condition should prevent it
Today I came across an interesting piece of code. It's more like a scientific question about the ruby parser.
We know everything in ruby is an object and every expression evaluates at least to nil.
But how is the following "assignment"…

JohnRoot
- 13
- 3