variable-assignment

Javascript multiple asignment re-evaluation or result passing?

允我心安 提交于 2020-01-06 03:18:01
问题 The multiple assignment (or is it called chaining ?) that I'm talking about is assignment such as: a = b = c = 2; ...after which a , b , and c are all equal to 2; My question of optimization is, given the following code: var dom1 = document.getElementById('layout_logos'); var dom2 = document.getElementById('layout_sitenav'); ... function layout_onscroll(){ ... dom1.style.height = dom2.style.top = maxLogoHeight - scrollTop; ... } From what I've been reading, I'm afraid the code in layout

HTML.DropDownListFor class assignment

心不动则不痛 提交于 2020-01-05 00:53:23
问题 Is it possible to assign my own class to the HTML.DropDownListFor() helper? 回答1: One of the overloaded method has an object htmlAttributes as last parameter in which you can specify extra attributes to be added to the generated html: Html.DropDownListFor(..., new { "class" = "myclassname" }; http://msdn.microsoft.com/library/ee703670.aspx 回答2: Didier's answer is mostly correct, but to define a class value in htmlAttributes object, you need to use this syntax: Html.DropDownListFor(..., new {

Intercepting Outlook category assignment events?

怎甘沉沦 提交于 2020-01-04 06:15:26
问题 Note this is not a duplicate of this similar but different question! My question is not how to intercept Category create / rename / delete events, but how to intercept when a user assigns a category to an item (contact, meeting etc). I am just starting to explore the Outlook object model, and I'm struggling to 'get' how it works. Any assistance in the right direction would be fantastic! I realise I'm not providing much detail and this seems like a 'please do it for me' type question, but I

Assignment / modification of values in an indexed subframe in Pandas

拟墨画扇 提交于 2020-01-04 01:56:49
问题 The documentation for indexing has few examples of assignment of a non-scalar right hand side. In this case, I want to modify a subset of my dataframe, and what I did prior to v.13 no longer works. import pandas as pd from numpy import * data = {'me':list('rttti'),'foo': list('aaade'), 'bar': arange(5)*1.34+2, 'bar2': arange(5)*-.34+2} df = pd.DataFrame(data).set_index('me') print df df.loc['r',['bar','bar2']]*=2.0 print df df.loc['t','bar']*=2.5 # Above fails: ValueError: Must have equal len

Are arrays implicitly created in PHP when one of its keys are assigned something?

馋奶兔 提交于 2020-01-03 18:32:07
问题 Just wishing to quickly verify this. It is different from my immediate experience from other languages whereby an array must first be declared before it can be filled with values. 回答1: Yes, PHP will automatically create an array given any of the following $foo[] = $bar; $foo[1] = $bar; $foo['bar'] = $bar; // and of course $foo = array(); // and soon to pass $foo = [1, 2, 3]; 回答2: PHP will create the array even without being implicitly declared, yes. $array[] = ... $array would be a valid

Are arrays implicitly created in PHP when one of its keys are assigned something?

走远了吗. 提交于 2020-01-03 18:32:04
问题 Just wishing to quickly verify this. It is different from my immediate experience from other languages whereby an array must first be declared before it can be filled with values. 回答1: Yes, PHP will automatically create an array given any of the following $foo[] = $bar; $foo[1] = $bar; $foo['bar'] = $bar; // and of course $foo = array(); // and soon to pass $foo = [1, 2, 3]; 回答2: PHP will create the array even without being implicitly declared, yes. $array[] = ... $array would be a valid

Groovy multiple assignment with a map

风格不统一 提交于 2020-01-03 10:18:53
问题 I am having a problem doing a multiple assignment statement for values in a map. def map = [a:1,b:2] (map.a, map.b) = [3,4] this throws an exception: expecting ')', found ',' at line: 2, column: 7 However, this works fine: def a = 1 def b = 2 (a, b) = [3,4] 回答1: Actually, you can do this if you cheat and use .with: Map map = [a: 1, b:2] map.with { (a, b) = [3, 4] } assert map.a == 3 assert map.b == 4 回答2: It doesn't support that. http://groovy.codehaus.org/Multiple+Assignment currently only

Is such assignment a good idea in C++

若如初见. 提交于 2020-01-02 07:14:14
问题 A lot of classes has assignment operator (operator=) the same code as in destructor and than very similar code of copy constructor. So is it good idea to implement the assignment in such way? Point& operator=(const Point& point) { if(&point != this) { //Call the destructor this->~Point(); //Make the placement new //Assignment is made because some compilers optimise such code as just // new Point; Point* p_n = new (this) Point(point); //We where placing in this place so pointers should be

Javascript increment while assigning

别说谁变了你拦得住时间么 提交于 2020-01-02 03:55:07
问题 I was having a conversation about the prefix increment operator, and we seem to have run into a disagreement. When running this code: var x = 0; x = ++x; is the second line equivalent to: x = (x = x + 1) OR x = (x + 1) It is hard to tell the difference because the results are identical (both result in x having a value of 1) I believe that the value is not saved to the original variable when the left hand side of the assignment is the variable itself. My counterpart disagrees and thinks the

Function `[<-` will _replace_ an element, but not append an _element_

感情迁移 提交于 2020-01-02 02:00:43
问题 I noticed the following when using '[<-' . I am successful at replacing elements but not at appending an element to the vector. Example: VarX <- integer() VarX[1] <- 11 `[<-`(VarX, 2, 22) VarX # [1] 11 # Expected the value of VarX to be: # [1] 11 22 # Also tried: `[<-`(VarX, i=2, value=22) VarX # [1] 11 However, if there is already a value at the index, the value does get replaced. VarX <- integer() VarX[1] <- 11 VarX[2] <- 99 VarX # [1] 11 99 `[<-`(VarX, 2, 22) VarX # [1] 11 22 Do I simply