Skip to main content

List Append

rascal-0.34.0

Synopsis

Append an element at the end of a list

Types

//

Exp₁Exp₂Exp₁ + Exp₂
list[T₁]T₂list[lub(T₁,T₂)]

Description

The operator + appends an element at the end of a list. The + is one of those Operators which are overloaded. It can also mean Insert or Concatenation for example.

Examples

rascal>[] + 1;
list[int]: [1]
rascal>[1] + 2;
list[int]: [1,2]

.Benefits:

.Pitfalls:

This is concatenation:

rascal>[1] + [2]
list[int]: [1,2]

To append a list to a list, use extra brackets:

rascal>[1] + [[2]]
list[value]: [
1,
[2]
]