About: Assignment operator   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

An assignment operator is a programming construct that gives a value to a variable. In NWScript, the basic (and most common) assignment operator is the equals sign (=). There are also assignment operators that update the value of a variable, namely +=, -=, *=, /=, %=, |=, and &=. For a simple assignment, the variable being assigned a value goes on the left of the operator, while the value to be assigned (an expression, possibly containing other operators) goes on the right. In the case where the value 1 is being assigned to a variable named x, the following line would be used. x = 1; int x = 1;

AttributesValues
rdfs:label
  • Assignment operator
rdfs:comment
  • An assignment operator is a programming construct that gives a value to a variable. In NWScript, the basic (and most common) assignment operator is the equals sign (=). There are also assignment operators that update the value of a variable, namely +=, -=, *=, /=, %=, |=, and &=. For a simple assignment, the variable being assigned a value goes on the left of the operator, while the value to be assigned (an expression, possibly containing other operators) goes on the right. In the case where the value 1 is being assigned to a variable named x, the following line would be used. x = 1; int x = 1;
dcterms:subject
abstract
  • An assignment operator is a programming construct that gives a value to a variable. In NWScript, the basic (and most common) assignment operator is the equals sign (=). There are also assignment operators that update the value of a variable, namely +=, -=, *=, /=, %=, |=, and &=. For a simple assignment, the variable being assigned a value goes on the left of the operator, while the value to be assigned (an expression, possibly containing other operators) goes on the right. In the case where the value 1 is being assigned to a variable named x, the following line would be used. x = 1; Having anything other than a variable to the left of the assignment operator is an error. Furthermore, the data type of the variable must match the type of expression to the right, with the one exception that an integer value can be assigned to a floating point variable (the conversion will be automatically added; however an explicit conversion may be better style at times). A simple assignment can also be used to initialize a variable, as in int x = 1; which simultaneously declares x to be a variable of type integer and gives that variable the value 1. The assignment operators that update the value of a variable are shorthand notation for using an arithmetic, string, or bitwise operator. Specifically, the assignment x *= 2 + cos(45); is equivalent to x = x * (2 + cos(45)); and similarly for the other operators. (The += operator can be used as shorthand for either numeric addition or string concatenation.) This allows for less text in the script, which can make the script more readable, at least for those familiar with these operators. A quirk of assignment operators, one that can confuse those new to programming, is that they are operators, and so they do have a value. The value of an assignment operator is the value assigned to the variable. This allows the value 2 to be assigned to the variables x and y with a line like the following. x = (y = 2); This is not a commonly used feature, at least not intentionally. It is more common to see this feature used unintentionally as part of a conditional expression, where the single equal sign was intended to be a test for equality (<a href="/mediawiki/Comparison_operator" title="Comparison operator">==</a>).
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software