# swap

## Description

Swaps the values of its inlets, preserving right-to-left ordering. The first outlet type is determined by its argument. The second outlet's type is always an int.

## Examples

## Arguments

### initial [number]

Optional

Sets an initial value for the number which is to be sent out the left outlet. If there is no argument, the initial value is 0. If there is an int argument or no argument, an int is sent out the left outlet. (The number sent out the right outlet is always a int.)

## Attributes

### Common Box Attributes

## Messages

### bang

In left inlet: Swaps and sends out the numbers currently stored in swap.

### int

#### Arguments

input
[int]

The number is sent out the right outlet, then the number in the right inlet is sent out the left outlet.

### (inlet1)

#### Arguments

input
[int]

The number is stored to be sent out the left outlet when a number is received in the left inlet.

### float

#### Arguments

input
[float]

The numbers are converted to int, unless there is a float argument, in which case the number received in the right inlet is stored as a float.

### (inlet1)

#### Arguments

input
[float]

The number is stored to be sent out the left outlet when a number is received in the left inlet.

### list

#### Arguments

left
[number]

right [number]

right [number]

In left inlet: The numbers are stored in swap. The first number is sent out the right outlet, then the second number is sent out the left outlet.

## Output

### float

If there is a float argument, the number sent out the left outlet is a float.

### int

When a number is received in the left inlet, the number in each inlet is sent out the opposite outlet.

## See Also

Name | Description |
---|---|

buddy | |

fswap | |

join | |

pack | |

unjoin | |

unpack | |

Max Basic Tutorial 17: Data Structures And Probability | Max Basic Tutorial 17: Data Structures And Probability |