-
Notifications
You must be signed in to change notification settings - Fork 1.7k
List.removeLast() docs error occurs if empty #35894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the suggestion. I'll probably phrase it differently, but it should be said somehow. |
@lrhn any ideas about alternative wording? Should this PR be closed if suggested wording does not satisfy your requirements? |
I'd also like to see it documented which error exactly will happen. But, since #26087 is I'd merge this PR easily as-is; for an extra mile of effort, I'd improve it further:
|
sdk/lib/core/list.dart
Outdated
@@ -537,6 +537,8 @@ abstract class List<E> implements EfficientLengthIterable<E> { | |||
/** | |||
* Pops and returns the last object in this list. | |||
* | |||
* An error occurs if the list is empty. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just say:
* The list must not be empty.
This is how we generally document prerequisites in the platform libraries. (We didn't always, which is why some documentation is not consistent, but this is the current official recommended approach.)
If a "must" requirement is not satisfied, the implementation will likely throw an Error
, but there are situations where the throwing is best-effort only (mainly concurrent modification). We do allow JavaScript compiled code to rely on the underlying JavaScript throwing, so we don't want to enforce a specific Dart error to throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Than you for the PR. I agree that it's a good idea to document the requirement.
We have a standard way of writing such prerequisites in platform library docs, so I have suggested that wording.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Than you for the PR. I agree that it's a good idea to document the requirement.
We have a standard way of writing such prerequisites in platform library docs, so I have suggested that wording.
74e4fce
to
12969e1
Compare
I changed the wording as suggested. |
Seems like this should be explicitly stated in the docs. I did not indicate the specific type of error because of #26087.