Questions tagged [assign]

Something related to an assignment operation, i.e. the process of changing the content of a variable to reflect some given value.

1695 questions
23
votes
4 answers

Updating one field in every element of a Matlab struct array

Suppose I have a struct array arr, where each element has a bunch of fields, including one called val. I'd like to increment each element's val field by some constant amount, like so: for i = 1:length(arr) arr(i).val = arr(i).val + 3; end This…
Carl
  • 435
  • 1
  • 4
  • 7
23
votes
6 answers

return an entire row of a multidimensional array in VBA to a one dimensional array

Is there any way to return the value of an entire row of a multidimensional array to a one dimensional array In VBA? Something like, arr_1dim = arr_2dim(3,:) is a matlab expression for assigning the row 3 of arr_2dim array to arr_1dim in one single…
surya teja3
  • 335
  • 1
  • 2
  • 5
22
votes
2 answers

PHP copy all object properties to this

I have an object in PHP, of the type MyObject. $myObject instanceof MyObject Now, in the class MyObject, there is a non-static function, and in there, I use the reference to "me", like $this, but I also have another object there. Is it possible,…
arik
  • 28,170
  • 36
  • 100
  • 156
22
votes
1 answer

Lazy evaluation in R – is assign affected?

I read this basic question on renaming objects and @Shane 's answer to it, pointing me to lazy evaluation. Now I wonder if assign is evaluated lazily, too. Just like here: assign("someNewName",someOldObject) rm(someOldObject) The reason why I…
Matt Bannert
  • 27,631
  • 38
  • 141
  • 207
22
votes
5 answers

AngularJS: dynamically assign controller from ng-repeat

I'm trying to dynamically assign a controller for included template like so:
But Angular complains that {{panel}} is…
Jakob Jingleheimer
  • 30,952
  • 27
  • 76
  • 126
21
votes
6 answers

Cannot Assign because it is a method group C#?

Cannot Assign "AppendText" because it is a "method group". public partial class Form1 : Form { String text = ""; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { …
puretppc
  • 3,232
  • 8
  • 38
  • 65
20
votes
8 answers

What is better in a foreach loop... using the & symbol or reassigning based on key?

Consider the following PHP Code: //Method 1 $array = array(1,2,3,4,5); foreach($array as $i=>$number){ $number++; $array[$i] = $number; } print_r($array); //Method 2 $array = array(1,2,3,4,5); foreach($array as &$number){ …
Aust
  • 11,552
  • 13
  • 44
  • 74
18
votes
2 answers

Weird SIGSEGV segmentation fault in std::string::assign() method from libstdc++.so.6

My program recently encountered a weird segfault when running. I want to know if somebody had met this error before and how it could be fixed. Here is more info: Basic info: CentOS 5.2, kernal version is 2.6.18 g++ (GCC) 4.1.2 20080704 (Red Hat…
yaobin
  • 2,436
  • 5
  • 33
  • 54
18
votes
2 answers

Error: Assigning to an array from an initializer list

I have a class such as: class dialog { public: double dReturnType[][5][3]; };   #include #include include using namespace std; #include "dialog.h"; int main(int argc, char *argv[]) { dialog People; …
Kearito
  • 211
  • 1
  • 2
  • 5
17
votes
3 answers

Re-assign column values in a pandas df

This question is related to rostering or staffing. I'm trying to assign various jobs to individuals (employees). Using the df below, `[Person]` = Individuals (employees) `[Area]` and `[Place]` = unique jobs `[On]` = How many unique jobs are…
user9394674
17
votes
1 answer

Object doesn't support property or method 'assign' - ie11 while using angular4

i am using angular4 for my project, when i first encountered this error i found some blog which asked me to install object-assign and use in the project. so i installed object-assign using npm install object-assign --save command and refrenced it in…
Lijin Durairaj
  • 3,341
  • 11
  • 31
  • 50
17
votes
1 answer

Assignment to replace value in nonlocal list

[[<- behaves differently for lists and environments when used on non-local objects: lst = list() env = new.env() (function () lst[['x']] = 1)() (function () env[['x']] = 1)() lst # list() as.list(env) # $x # [1] 1 In other words, if the target…
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
17
votes
4 answers

Assignment of objects in C++

To contextualize my question, I'm using a Matrix class with the following definitions: Matrix(unsigned int, unsigned int); // matrix of the given dimension full of zeroes Matrix(Matrix*); // creates a new matrix from another one int &operator()(int,…
user1493813
  • 981
  • 1
  • 8
  • 16
16
votes
1 answer

How to pandas df.assign() with variable names?

I want to add a new column in a dataframe with values from some other dataframe. My new column name is a variable and I cannot hardcode it. new_column = "my_new_column_name" df = df.assign(new_column=other_df['Column1'].values) The problem is…
eiram_mahera
  • 950
  • 9
  • 25
16
votes
1 answer

property "assign" and "retain" for delegate

For iOS developers, delegates are used almost everywhere. And seems like that we need to use "assign" instead of retain for a delegate like this @property(assign) id delegate; The reason is to avoid the circular loop issue Why are Objective-C…
Forrest
  • 122,703
  • 20
  • 73
  • 107