src/swipl-devel/packages/xpce/man/refmanual/md/assign.md

class assign {#class-assign}

Class assign defines an assignment statement for a var object. An assign is an executable object that, when executed, evaluates its <-value and assigns its <-var with this value. See class var for a discussion on variables and assignments (var ->assign).

Class assign is first of all introduced for syntactical cosmetical reasons. The following two code objects perform the same function:

assign(Var, Value).
message(Var, assign, Value).

An assign object demands its first argument to be an instance of class var. This implies that named variables can be referred to much more elegant. Executing

assign(x, 10)

Will assign 10 to the variable named x, while the message variant would be:

message(?(@variables, member, x), assign, 10)

See also <-convert.

@see class var

Instance variables {#class-assign-instvars}

Send methods {#class-assign-send}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.