Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Assignment (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Value of an assignment== In some programming languages, an assignment statement returns a value, while in others it does not. In most [[expression-oriented programming languages]] (for example, [[C (programming language)|C]]), the assignment statement returns the assigned value, allowing such idioms as <code>x = y = a</code>, in which the assignment statement <code>y = a</code> returns the value of <code>a</code>, which is then assigned to <code>x</code>. In a statement such as {{code|2=c|1=while ((ch = getchar()) != EOF) {β¦} }}, the return value of a function is used to control a loop while assigning that same value to a variable. In other programming languages, [[Scheme (programming language)|Scheme]] for example, the return value of an assignment is undefined and such idioms are invalid. In [[Haskell (programming language)|Haskell]],<ref name="haskell">{{cite book |last=Hudak |first=Paul |year=2000 |title=The Haskell School of Expression: Learning Functional Programming Through Multimedia |location=Cambridge |publisher=Cambridge University Press |isbn=0-521-64408-9}}</ref> there is no variable assignment; but operations similar to assignment (like assigning to a field of an array or a field of a mutable data structure) usually evaluate to the [[unit type]], which is represented as <code>()</code>. This type has only one possible value, therefore containing no information. It is typically the type of an expression that is evaluated purely for its side effects.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)