assignment

Assigning values to the datagridview cell.

How can I assign values of the textbox to the datagridview cell ? ...

MATLAB matrix replacement assignment gives error

I tried to update some part of a matrix, I got the following error message: ??? Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts My code tries to update some values of a matrix that represent a binary image. My code is as follows: outImage(3:5,2:4,1) = max(imBinary(3:5,2:4,1)); When I delete last parame...

Saving a select count(*) value to an integer (SQL Server)

Hi everyone, I'm having some trouble with this statement, owing no doubt to my ignorance of what is returned from this select statement: declare @myInt as INT set @myInt = (select COUNT(*) from myTable as count) if(@myInt <> 0) begin print 'there's something in the table' end There are records in myTable, but when I run the code...

Java: += equivalence

Super quick question to refresh my mind: Is: x -= y; equivalent to: x = x - y; Thanks! ...

how to assign an object to smarty templates?

i created a model object in PHP class User { public $title; public function changeTitle($newTitle){ $this->title = $newTitle; } } How do i expose the property of a User object in smarty just by assigning the object? I know i can do this $smarty->assign('title', $user->title); but my object has something like over 20 p...

Does this javascript statement affects performance?

Hi guys, I'm writing a function add_event as the following shows: function add_event(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; if(document.addEventListener){ add_event = function(o, event_type, callback, capture){ o = typeof o === "string" ? document.getEl...

Python: avoiding if condition?

Which is better? if not var: var = get_var() (or) var = var or get_var() Also, How do I know the better of the two? edit:One more option from steve, var = var if var else get_var() ...

if an object property is another object, how do i access that object-property's property or method in smarty?

class A { public $property1; public $objB; public __construct(){ $this->property1 = 'test'; $this->objB = new B(); } } class B { public $title; public __construct(){ $this->title = 'title1'; } } so now i do this in the .php file $a = new A(); in my .tpl i want to display $a->objB->title how do i do that...

When initializing in C# constructors what's better: initializer lists or assignment?

Class A uses an initializer list to set the member to the paramter value, while Class B uses assignment within the constructor's body. Can anyone give any reason to prefer one over the other as long as I'm consistent? class A { String _filename; A(String filename) : _filename(filename) { } } class B { String _f...

How would I express a chained assignment in Scala?

How would I express the following java code in scala? a = b = c; By the way, I'm re-assigning variables (not declaring). ...

How to assign the output of a command to a variable?

Hi, this is probably a very stupid question; in a bash script, given the output of, for instance; awk '{print $7}' temp it gives 0.54546 I would like to give this to a variable, so I tried: read ENE <<< $(awk '{print $7}' temp) but I get Syntax error: redirection unexpected Could you tell me why, and what is the easiest way t...

C++ union assignment, is there a good way to do this?

I am working on a project with a library and I must work with unions. Specifically I am working with SDL and the SDL_Event union. I need to make copies of the SDL_Events, and I could find no good information on overloading assignment operators with unions. Provided that I can overload the assignment operator, should I manually sift thro...

Can I have two names for the same variable?

The short version of the question: I do: x = y. Then I change x, and y is unchanged. What I want is to "bind" x and y in such a way that I change y whenever I change x. The extended version (with some details): I wrote a class ("first" class) which generates objects of another class ("second" class). In more details, every object of t...

We say Reference are const pointers. Why I am able to assign a new variable to ref B? The below program compiles successfully.

#include<iostream.h> int main() { int a=10; int &b=a; cout<<"B"<<'\n'<<b; cout<<"A"<<'\n'<<a; b=100; cout<<"B"<<'\n'<<b; cout<<"A"<<'\n'<<a; int c=20; b=c; cout<<"C"<<'\n'<<c; cout<<"B"<<'\n'<<b; } ...

unable to return 'true' value in C function

If Im trying to check an input 5 byte array (p) against a 5 byte array stored in flash (data), using the following function (e2CheckPINoverride), to simply return either a true or false value. But it seems, no matter what I try, it only returns as 'false'. I call the function here: if (e2CheckPINoverride(pinEntry) == 1){ PTDD_PTDD1 =...

C++ is there a difference between assignment inside a pass by value and pass by reference function?

Is there a difference between foo and bar: class A { Object __o; void foo(Object& o) { __o = o; } void bar(Object o) { __o = o; } } As I understand it, foo performs no copy operation on object o when it is called, and one copy operation for assignment. Bar performs one copy operation on object o when it is ...

Java assignment issues - Is this atomic?

Hi, I've got some questions about Java's assigment. Strings I've got a class: public class Test { private String s; public synchronized void setS(String str){ s = s + " - " + str; } public String getS(){ return s; } } I'm using "synchronized" in my setter, and avoiding it in my getter, because in my app, there are a to...

Multiple Unpacking Assignment in Python when you don't know the sequence length

The textbook examples of multiple unpacking assignment are something like: import numpy as NP M = NP.arange(5) a, b, c, d, e = M # so of course, a = 0, b = 1, etc. M = NP.arange(20).reshape(5, 4) # numpy 5x4 array a, b, c, d, e = M # here, a = M[0,:], b = M[1,:], etc. (ie, a single row of M is assigned each to a through e) (My Q ...

Could the assign function for containers possibly overflow?

I ran into this question today and thought I should post it for the community's reference and/or opinions. The standard C++ containers vector, deque, list, and string provide an assign member function. There are two versions; I'm primarily interested in the one accepting an iterator range. The Josuttis book is a little ambiguous with ...

Overload assignment operator for assigning sql::ResultSet to struct tm

Are there exceptions for types which can't have thier assignment operator overloaded? Specifically, I'm wanting to overload the assignment operator of a struct tm (from time.h) so I can assign a sql::ResultSet to it. I already have the conversion logic: sscanf(sqlresult->getString("StoredAt").c_str(), "%d-%d-%d %d:%d:%d", &TempTimeS...