Intermediate Enumerables • Exercise 3/5

Partition

00:00
0
15 points

Instructions

Create a function split_by_sign that takes an array of numbers
and returns two arrays: one with non-negative numbers (>= 0) and
one with negative numbers.

Use the partition method:
```ruby
[1, -2, 3, -4].partition { |n| n >= 0 }

=> [[1, 3], [-2, -4]]


Return format: `[non_negatives, negatives]`

Your Code

Results

Click "Run Tests" to see results