What's the difference b/w next() and hasNext()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2014 06:53 AM
- 34,846 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2014 07:15 AM
hasNext() either returns true or false while next() will actually iterate to the record.
So I could do:
gr.query();
if (gr.next()) {
gr.field = 'value';
gr.update();
}
but this won't update anything:
gr.query();
if (gr.hasNext()) {
gr.field = 'value';
gr.update();
}
So if there are one or more records contained in your gr set, hasNext() will return true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2014 07:28 AM
Hi Brad, in 2nd scenario, gr doesn't iterate to the actual record? if there is only one match, what is contained in the gr when using hasNext?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2023 05:12 AM
When I was try with above code in nest() if I got the updated record but not updated in case of hasNext().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hey Brad, Very clear presentation via code;
I like to add performance & business context to both hasNext() & next() methods
Performance:
hasNext() : best - very efficient & light on system.
next(): Heavy on system.
Business Context:
1. Do we have any p1 - Incident not resolved this morning - hasNext()
well, you are just looking for YES or NO answer, so that you can inform the team to prioritize p1.
2. who is working on the p1-incident - next()
you can get the Engineer details who is handling the situation.
