Question: Where `entries` is a Hash:

```
entries = { foo: 1, bar: 2 }

```

This is the syntax I'm familiar with:

```
entries.map { |key, val| "#{key} #{val}" }
#=> ["foo 1", "bar 2"]

```

This is the syntax I came upon in a tutorial:

```
entries.map { |key_val| "#{key_val.first} #{key_val.last}" }
#=> ["foo 1", "bar 2"]

```

I'm new to Ruby, so I'm surprised that both syntaxes even work. My question are:

1. Is there any difference between the two?
2. Why does this work - Is it because the hash table object implements the `Enumerable` interface (which provides the `map` method) in two separate ways?

Answer: 
No, it has nothing to do with hashes and enumerables (well, almost). It is a thing I call "array destructuring". Ruby has a nice way of taking arrays apart. Suppose you have this two-element array

```
ary = [1, 2]

```

You can get its elements by accessing them individually

```
a = ary.first # or ary[0]
b = ary.last # or ary[-1]

```

Or instead you can "destructure" the array by assigning array directly to the variables

```
a, b = ary

```

`a` will be the first element of the array, `b` - the second (also the last, in this particular case).

Same thing happens in your example. Enumerable's `each` (which is what `map` calls), when used on a hash, yields arrays of two elements, a key and its value.

Now, if the block has only one parameter, it's gonna be that array. If it has two, your array will be taken apart for you.

And yes, prefer the first method. More readable.
In Ruby, [`Hash#each`](http://docs.ruby-lang.org/en/2.3.0/Hash.html#method-i-each) is an alias of `Hash#each_pair`, in other words, both methods point to [same implementation](https://github.com/ruby/ruby/find/trunk#L4296). The block passed to `each` always receives key-value pair in the form of two-element array.

Since all the methods of [`Enumerable`](http://docs.ruby-lang.org/en/2.3.0/Enumerable.html) module are implemented based on `each` method, all the enumerable methods include `map` will receive the key-value pair as an array parameter.

This enables the usage of two syntaxes that is mentioned in question.