Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • This is the same as both of the existing answers from 10+ years ago, but with less information and more steps. The intermediate list you're using to store the results of the query is not required. Commented Apr 4, 2024 at 11:45
  • no,it is different as we are using global variable in it and you are correct we don't need a list but it is a simplified way of expressing the technicality. you can directly pass the query into the map instance. Commented Apr 6, 2024 at 11:08
  • we are not using any looping over here as well \ Commented Apr 6, 2024 at 11:10
  • The global variable distinction doesn't make any difference here (and global should generally be avoided unless you know it's required). Neither of the existing answers use loops. Commented Apr 6, 2024 at 12:30
  • I have that requirement where we need to use the map data in another method which needs a global variable to perform this. Commented Apr 7, 2024 at 14:47