Question: I can only find methods that look for specific elements of an array.

During my objects.each |a| loop, I want to know when I'm at the final element so I can have a loop like:

```
objects.each |a|
   if objects.hasNext()
       puts a.name + ","
   else
       puts a.name

```

Iterator's hasNext() determines if the Array's iterator has another element after the one currently being evaluated.

I want to emphasize that I'm looking to print out these values, not turn them in to an Array. .join is not what I'm looking for here.

Answer: 
In the Ruby library iterators are implemented as internal iterators in contrast to Java which implements external iterators. The key difference between the two is that the former are designed to not let the client control the iteration, while the latter leave to the client this responsibility. 

The purpose of a method like `hasNext` is to control iteration directly, thus in Ruby no such thing exists. Methods like `peek` and `next` defined by `Enumerator` are, I guess, not intended to control iteration directly but to implement custom internal iterators.

That said, your problem is easily solved with this code:

```
puts objects.map(&:name).join(', ')

```

However sometimes could be useful to concoct your own internal iterator using an `Enumerator` object:

```
module Enumerable
  def puts_each_with_separator(separator)
    enum = each
    loop do
      print yield(enum.next)
      enum.peek rescue break
      print separator
    end
    puts
  end
end

objects.puts_each_with_separator(', ', &:name)

```
> 
> I want to emphasize that I'm looking to print out these values, not
>  turn them in to an Array. .join is not what I'm looking for here.
> 
> 
> 

Actually, I think .join is exactly what you're looking for. The result of .join is a string, not an array, so

```
puts objects.join(",") 

```

does what you say you want.