[GODRIVER-239] Improve Document.ElementAt usability Created: 13/Feb/18  Updated: 28/Oct/23  Resolved: 20/Feb/18

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.0.2

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Samuel Rossi (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: GODRIVER Alpha 2 UX

 Description   

Currently, the Document type has 2 methods for looking up an element at an index: ElementAt and MustElementAt. Since they sort far apart and don't have the same prefix it is difficult for users to find. To enable a more discoverable API and to more closely align with the semantics of the slice type in Go, change ElementAt to just return the Element and panic if out of bounds, remove the MustElementAt method, and add an ElementAtOK method, which will return false if the index is out of bounds. This provides a safety option while also making the two methods more discoverable.



 Comments   
Comment by Githook User [ 20/Feb/18 ]

Author:

{'email': 'saghmrossi@gmail.com', 'name': 'Saghm Rossi', 'username': 'saghm'}

Message: GODRIVER-239 Improve Document.ElementAt usability

Change-Id: Ic71f026e4aa9d7ce5ebd2382ffbe972261476702
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/d533931400df2cb09f1c0fe1f124e9d3156c62ae

Comment by Samuel Rossi (Inactive) [ 20/Feb/18 ]

Code review url: https://review.gerrithub.io/c/400724/

Generated at Thu Feb 08 08:33:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.