assignment

Adding custom CSS into a new Moodle assignment

I'm working on a new Moodle Assignment plugin. How can I include a custom CSS to my plugin? I'm using Moodle 1.9.7. Thanks in advance. ...

Value before variable

I'm looking at some SQL code which has a WHERE clause like this: WHERE 'USD' = CCY I asked the writer why he's putting the value on the left hand side, and he said it's best practice to do so, stemming from C++ where people could mistakenly assign the value instead of comparing equality by forgetting the second equals sign. I've neve...

Difference between creating a local variable and assigning to ivar and directly assigning to ivar?

Hello, I have always wondered why all apple code samples use code like this: UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; self.navigationController = aNavigationController; [self.view addSubview:[navigationController view]]; [aNavigationCont...

Method of Multiple Assignment in Python

I'm trying to prepare for a future in computer science, so I started with ECMAScript and I am now trying to learn more about Python. Coming from ECMAScript, seeing multiple assignments such as a, b, c = 1, 2, 3 leaves me bewildered for a moment, until I realize that there are multiple assignments going on. To make things a bit clearer, I...

Unexpected object assignment

class TrafficData(object): def __init__(self): self.__data = {} def __getitem__(self, epoch): if not isinstance(epoch, int): raise TypeError() return self.__data.setdefault(epoch, ProcessTraffic()) def __iadd__(self, other): for epoch, traffic in other.iteritems(): # th...

Why is the php assignment operator acting as an assignment by reference in this case?

I have some code that appears to behave differently between php4 and php5. This code below: class CFoo { var $arr; function CFoo() { $this->arr = array(); } function AddToArray($i) { $this->arr[] = $i; } function DoStuffOnFoo() { for ($i = 0; $i < 10; ++$i) { ...

Mass assignment on construction from within ruby.

Possible Duplicate: Idiomatic object creation in ruby Sometimes it's useful to assign numerous of a constructed arguments to instance variables on construction. Other than the obvious method: def initialize(arg1, arg2, arg3) @arg1, @arg2, @arg3 = arg1, arg2, arg3 end Is there a more concise idiom for achieving the same re...

Is there a cleaner or more efficient to do this Python assignment?

Here's the code I have now: lang = window.get_active_document().get_language() if lang != None: lang = lang.get_name() Is there a better way to do that? I'm new to Pythonic and was wondering if there's a more Python way to say "something equals this if x is true, else it equals that." Thanks. ...

Question about OSI layer

I am a network programming newbie. I would like to confirm thta my answer is right or not. Would anyone mind helping me to check the answers. Thank you very much! Which OSI protocol layer does a repeater correspond to? Physical layer Which OSI protocol layer does a bridge correspond to? Transport layer??? Which OSI protocol layer d...

help for a java assignment

Hi, I want to write a messenger application with java. I want to send smily pictures. I have written this code but it doesn’t work. public class MyClient extends JFrame implements IClient { … JEditorPane editorPane=new JEditorPane(); final String SMILE = ClassLoader.getSystemClassLoader().getResource("images/1.gif").toString(); … ...

Introductory Computer Science assignments

I will be teaching my first university level Computer Science course this summer, and I'm currently working on coming up with ideas for fun assignments that the students will complete. The course is the second in the program, covering analysis of algorithms and basic data structures such as stacks, queues, lists, trees, etc. I have a...

Should I assign a value to a variable when I declare it in Java?

I have a code with the following sequence of lines: Socket echoSocket = null; ... something ... echoSocket = new Socket("taranis", 7); I do not understand why we want to have a first line. Well I know that Java is unable to define a type of the variable from its value. It's why first we need to tell that echoSocket is variable which h...

Intercepting Outlook category assignment events?

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 as...

Multiassignment in VB like in C-Style languages

Is there a way to perform this in VB.NET like in the C-Style languages: struct Thickness { double _Left; double _Right; double _Top; double _Bottom; public Thickness(double uniformLength) { this._Left = this._Right = this._Top = this._Bottom = uniformLength; } } ...

C++ Copy constructor, temporaries and copy semantics

For this program #include <iostream> using std::cout; struct C { C() { cout << "Default C called!\n"; } C(const C &rhs) { cout << "CC called!\n"; } }; const C f() { cout << "Entered f()!\n"; return C(); } int main() { C a = f(); C b = a; return 0; } the output I get is: Entered f()! Default C called! ...

transformation in matlab

how to use matrix to transform to curve in matlab??? --scaling on the xy plane --translation on the xy plane --translation in space --rotation on plane about the origin by angle --rotation in space about the z-axis by angle how i want write the source code? thank you!! ...

How do I do multiple assignment in MATLAB?

Here's an example of what I'm looking for: >> foo = [88, 12]; >> [x, y] = foo; I'd expect something like this afterwards: >> x x = 88 >> y y = 12 But instead I get errors like: ??? Too many output arguments. I thought deal() might do it, but it seems to only work on cells. >> [x, y] = deal(foo{:}); ??? Cell content...

Why does the Java compiler complain about a local variable not having been initialized here?

int a = 1, b; if(a > 0) b = 1; if(a <= 0) b = 2; System.out.println(b); If I run this, I receive: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The local variable b may not have been initialized at Broom.main(Broom.java:9) I know that the local variables are not initialized and is your duty to do t...

vector assignation on uninitialized memory chunk and similar issues

vector<vector<string> > test for example. g++, you can do test.reserve(10); test[0] = othervector; test[9] = othervector; It doesn't crash. Theory says you shouldn't do it like that because you are assigning a vector to a chunk of memory that believes it is a vector. But it works just like the next one: #include <string> #include <...

Multiple assignment of non-tuples in scala

Just to clarify, when I say multiple assigment, parallel assignment, destructuring bind I mean the following pattern matching gem scala> val (x,y) = Tuple2("one",1) x: java.lang.String = one y: Int = 1 which assigns "one" to x and 1 to y. I was trying to do val (x,y) = "a b".split() I was expecting that scala would attempt to patt...