---
title: "randomSplit(by:seed:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/sequence/randomsplit(by:seed:)-9637d"
---

# randomSplit(by:seed:)

Generates two generic arrays by randomly splitting the elements of the sequence.

## Declaration

```swift
func randomSplit<T>(by proportion: Double, seed: Int? = nil) -> (ArraySlice<T>, ArraySlice<T>) where T == Self.Element
```

## Parameters

- `proportion`: A proportion in the range [0.0, 1.0].
- `seed`: A seed number for a random-number generator.

## Return Value

Return Value A tuple of array slices.
