# tf.data.experimental.get_next_as_optional

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/data/experimental/get_next_as_optional) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/data/ops/iterator_ops.py#L808-L828) |

Returns an `Optional` that contains the next value from the iterator.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.data.experimental.get_next_as_optional`](https://www.tensorflow.org/api_docs/python/tf/data/experimental/get_next_as_optional)

<br />

    tf.data.experimental.get_next_as_optional(
        iterator
    )

If `iterator` has reached the end of the sequence, the returned `Optional`
will have no value.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `iterator` | A [`tf.compat.v1.data.Iterator`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/compat/v1/data/Iterator) object. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An `Optional` object representing the next value from the iterator (if it has one) or no value. ||

<br />