User Tools

Site Tools


harlowe:move

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:move [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(move: //​...[[harlowe:​VariableToValue|VariableToValue]]//​) -> //​Instant//​**
  
 +A variant of [[harlowe:​put|(put:​)]] that deletes the source value after copying it - in effect
 +moving the value from the source to the destination.
 +
 +=== Example usage: ===
 +
 +''​%%(move:​ $arr's 1st into $var)%%''​
 +
 +=== Rationale: ===
 +
 +You'll often use data structures such as [[harlowe:​array|array]] or [[harlowe:​datamap|datamap]] as storage for values
 +that you'll only use once, such as a list of names to print out. When it comes time
 +to use them, you can remove it from the structure and retrieve it in one go.
 +
 +=== Details: ===
 +
 +You must use the ''​%%into%%''​ keyword, like [[harlowe:​put|(put:​)]],​ with this macro. This is because, like [[harlowe:​put|(put:​)]],​
 +the destination of the value is on the right, whereas the source is on the left.
 +
 +You can also set multiple variables in a single (move:) by separating each VariableToValue
 +with commas: ''​%%(move:​ $a's 1st into $b, $a's 2nd into $c)%%'',​ etc.
 +
 +If the value you're accessing cannot be removed - for instance, if it's an array'​s ''​%%length%%''​ -
 +then an error will be produced.
 +
 +=== See also: ===
 +
 +[[harlowe:​push|(push:​)]],​ [[harlowe:​set|(set:​)]]
harlowe/move.txt ยท Last modified: 2017/10/09 20:39 (external edit)