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: 
No, there isn't. However, note that `hasNext` is not an `Array` operation in Java, either. It's an `Iterator` operation, and Ruby's equivalent to Java's `Iterator` is `Enumerator`, not `Array`.

However, Ruby's `Enumerator` works a little bit different than Java's: instead of asking whether there is a next element, and then advancing the iterator, you simply try to look at the next element and it throws a `StopIteration` exception when there are no more elements.

So, the equivalent to Java's

```
iter.hasNext);

```

would be roughly

```
begin
  enum.peek
  true
rescue StopIteration
  false
end

```

However, you almost *never* iterate manually in Ruby. Instead, you use higher-level iteration methods such as `join`, `flat_map`, `group_by`, `uniq`, `sort`, `sort_by`, `inject`, `map`, `each_with_object`, `each` etc.

For example:

```
%w(pretty ugly stupid).join(', ') # => 'pretty, ugly, stupid'

```
> 
> 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.