Returns the element at the specified position in an iterable. <p><b>{@code Stream} equivalent:</b> {@code stream.skip(position).findFirst().get()} (throws {@code NoSuchElementException} if out of bounds) @param position position of the element to return @return the element at the specified positio
(Iterable<T> iterable, int position)
| 766 | * the size of {@code iterable} |
| 767 | */ |
| 768 | @ParametricNullness |
| 769 | public static <T extends @Nullable Object> T get(Iterable<T> iterable, int position) { |
| 770 | checkNotNull(iterable); |
| 771 | return (iterable instanceof List) |
| 772 | ? ((List<T>) iterable).get(position) |
| 773 | : Iterators.get(iterable.iterator(), position); |
| 774 | } |
| 775 | |
| 776 | /** |
| 777 | * Returns the element at the specified position in an iterable or a default value otherwise. |