Rubinextraktelemente aus Array

Suppose you have an array of hashes like this:

```ruby
arr = [{a: 1, b: 2}, {c: 3, d: 4}, {e: 5, f: 6}]
```

You can extract the values corresponding to a given key like this:

```ruby
arr.map { |h| h[:a] }
# => [1, nil, nil]
```

```ruby
arr.map { |h| h[:b] }
# => [2, nil, nil]
```

```ruby
arr.map { |h| h[:c] }
# => [nil, 3, nil]
```

```ruby
arr.map { |h| h[:d] }
# => [nil, 4, nil]
```

```ruby
arr.map { |h| h[:e] }
# => [nil, nil, 5]
```

```ruby
arr.map { |h| h[:f] }
# => [nil, nil, 6]
```

If you want to get all the values for all the keys, you can use `#values`:

```ruby
arr.map { |h| h.values }
# => [[1, 2], [3, 4], [5, 6]]
```
Caffeinated Developer