Gems

Learn what gems are and how to use them in Ruby.

We'll cover the following...

What are gems?

Until now, all of our experiments have been quite straightforward. However, with two-dimensional arrays, we may have noticed the lack of visual cues. For example, the array for the “Sea Battle” game doesn’t look very intuitive in the console:

$ irb
> Array.new(10) { Array.new(10) }
 => [[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]]

We still can understand what it is, but can we quickly find out the fifth row and second column? It would help if we ...