Keyword

# Return

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Returns flow of execution to the calling method.

## Usage

``` xojo
Return [ value ]
```

| Part  | Type | Description                             |
|-------|------|-----------------------------------------|
| value | Any  | Value returned to the calling function. |

## Notes

Methods automatically <span class="title-ref">Return</span> when you reach the end of the code in the method. You can use the <span class="title-ref">Return</span> command to exit a method early based on a condition. You must specify a <span class="title-ref">Return</span> value for functions and events that are declared to have a <span class="title-ref">Return</span> value. The <span class="title-ref">Return</span> value must match the type in the declaration. The <span class="title-ref">Return</span> value can be an array or a single value. If you want to <span class="title-ref">Return</span> an array, put empty parentheses after the name of the data type in the <span class="title-ref">Return</span> Type area for the declaration in the Inspector. For example, if you want to <span class="title-ref">Return</span> an array of Integers, this would be the <span class="title-ref">Return</span> type:

``` xojo
Integer()
```

If you need to <span class="title-ref">Return</span> a multi-dimensional array, place one fewer commas in the parentheses than dimensions. For example, to <span class="title-ref">Return</span> a two-dimensional array of Doubles, use this as the <span class="title-ref">Return</span> type:

``` xojo
Double(,)
```

## Sample code

``` xojo
' Exit early from a method
Sub Test(value As String)
  If value = "Hello" Then Return

  Label1.Text = value
End Sub

' Return from a function
Function calc(value As Integer) As Integer
  value = value * 2
  Return value
End Sub
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Exit</api/language/loops/exit>`, `Function</api/language/function>`, `Sub</api/language/sub>` statements.

</div>
