assignment-operator Questions

1

Solved

I understand that list assignment flattens its left hand side: my ($a, $b, $c); ($a, ($b, $c)) = (0, (1.0, 1.1), 2); say "\$a: $a"; # OUTPUT: «$a: 0» say "\$b: $b"; # OUTPUT: «$...

2

Solved

I frequently need to implement C++ wrappers for "raw" resource handles, like file handles, Win32 OS handles and similar. When doing this, I also need to implement move operators, since the default ...

3

Solved

For properly handling object copying, the rule of thumb is the Rule of Three. With C++11, move semantics are a thing, so instead it's the Rule of Five. However, in discussions around here and on th...
Dermatoglyphics asked 18/8, 2017 at 10:17

6

Solved

I just realized that I was using =+ instead of the operator += and my program was doing all sorts of weird and unexpected things. Eclipse didn't give me an error of any kind so I assume that =+ is ...
Confusion asked 20/6, 2013 at 6:44

4

Solved

What does the =& (equals-ampersand) assignment operator do in PHP? Is it deprecated?
Dunno asked 20/11, 2009 at 4:28

7

Solved

The following code sample prints 1.5. float a = 3; float b = 2; a /= b; System.out.println(a); I don't understand what the /= operator does. What is it supposed to represent?
Onym asked 4/12, 2012 at 3:56

6

Solved

If I override operator= will the copy constructor automatically use the new operator? Similarly, if I define a copy constructor, will operator= automatically 'inherit' the behavior from the copy co...
Decarbonate asked 20/3, 2011 at 11:41

2

Solved

I'm working with Liquid templates for Shopify. I want some elements to show up only if the month happens to be December. Since there are multiple elements that need this, I want to set a variable a...

2

Rust has several operators that cannot be chained (==, < for example). But the assignment operator = can be chained. a = b = 10; In this case, 10 is assigned to b, and unit () is assigned to a....
Fan asked 11/1, 2021 at 4:59

11

Solved

Suppose we have: >>> x = 1 >>> y = 2 If we try assigning both values at once like so: >>> x, y = y, x+y >>> x 2 >>> y 3 Then we get a different result...

3

Solved

I have two data tables, DT1 and DT2: set.seed(1) DT1<-data.table(id1=rep(1:3,2),id2=sample(letters,6), v1=rnorm(6), key="id2") DT1 ## id1 id2 v1 ## 1: 2 e 0.7383247 ## 2: 1 g 1.5952808 ## 3: 2 ...
Gaea asked 6/2, 2013 at 3:20

8

Solved

I answered the question about std::vector of objects and const-correctness, and received a comment about undefined behavior. I do not agree and therefore I have a question. Consider the class with ...
Fulcher asked 9/11, 2010 at 16:42

2

Solved

I'm confused about '=' operator, and tf.identity(), I thought '=' is to just make a reference of the tensor, and identity is to make a copy, e.g., with ref = x ref = ref*0 sess.run(x) I will get...

3

Solved

In perl5 you could think of \ as a pointer and dereference that pointer by prefixing with the specific sigil or ->. You had also typeglobs that made the symbol explicit. In perl5 the underlying ...
Tenet asked 24/7, 2020 at 9:11

5

Consider: if (a=5) { /* do something */ } How does the assignment work as a condition? Is it based on non-zero value of l-value?
Dogma asked 24/7, 2011 at 14:28

2

Solved

I have face this weird behavior I can not find explications about. MWE: l = [1] l += {'a': 2} l [1, 'a'] l + {'B': 3} Traceback (most recent call last): File "<input>", line 1, in <modu...
Ravi asked 27/4, 2020 at 10:48

1

Solved

I have a base class A and two derived classes B and C. B defines the = operator, taking the base class A as parameter. When calling = on class B, sometimes the operator of base class A is called i...
Galway asked 18/4, 2020 at 15:53

1

Solved

I was doing some stuff and I ran into a problem that I can't understand. I simplified the code to get that: function somePromise() { return new Promise((resolve, reject) => { resolve(1)...
Contradictory asked 7/3, 2020 at 10:11

4

Solved

int main() { int y; int x{ y = 5 }; //x is 5 } How is this possible, since y = 5 is not a calculable expression? Also, why doesn't the compiler or IDE complain about main() not returning an i...
Dude asked 18/10, 2019 at 9:17

6

Solved

If I'm using something like this: xr.Settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings; What precisely is the |= accomplishing?
Squirrel asked 19/12, 2012 at 18:5

5

Solved

I encountered a statement in Java while ((line = reader.readLine()) != null) { out.append(line); } How do assignment operations return a value in Java? The statement we are checking is line = ...
Arborescent asked 2/7, 2016 at 19:52

5

Solved

There is a class in our code, say class C. I want to create a vector of objects of class C. However, both the copy constructor and assignment operator are purposely declared to be private. I don't ...
Casseycassi asked 11/5, 2011 at 4:4

3

Solved

It is commonly known that when implementing an assignment operator one has to protect against self-assignment, at least when the class has non-POD members. Usually it is (or is equivalent to): Foo...
Needham asked 26/5, 2019 at 18:27

2

Solved

In C++, the expression left() = right() evaluates right() left() in that sequence. The right() goes first, as has been discussed here. I cannot think of a reason for right() to go first. Can y...
Singband asked 27/3, 2019 at 21:54

2

Solved

The C++17 standard revised the definitions of the order of operations for the C++ language by a rule stating, to the effect: In every simple assignment expression E1=E2 and every compound assig...
Isborne asked 11/10, 2018 at 14:22

© 2022 - 2024 — McMap. All rights reserved.