You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
loneElement and loneElementOption: extension methods for Iterable (#1827)
* loneElement and loneElementOption: extension methods for Iterable
* remove 'hint' from loneElementOption
* remove 'hint' from loneElementOption
* moved to flatgraph. only change left: deprecation `onlyChecked`
* latest fg
"please use `.loneElement` from flatgraph (mixed into the generated `language` packages) instead, which has a better name and will throw if the iterable has more than one element (rather than just log.warn)",
11
+
since ="1.7.42 (July 2025)"
12
+
)
10
13
defonlyChecked:T= {
11
14
if (iterable.iterator.hasNext) {
12
15
valres= iterable.iterator.next()
13
16
if (iterable.iterator.hasNext) {
14
17
logger.warn("iterator was expected to have exactly one element, but it actually has more")
15
18
}
16
19
res
17
-
} else { thrownewNoSuchElementException() }
18
-
}
19
-
}
20
-
21
-
/** A wrapper around a Java iterator that throws a proper NoSuchElementException.
22
-
*
23
-
* Proper in this case means an exception with a stack trace. This is intended to be used as a replacement for next()
24
-
* on the iterators returned from TinkerPop since those are missing stack traces.
0 commit comments