Skip to content
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

.first throws an error if used with less than 2 values #26

Closed
renatoargh opened this issue Apr 12, 2021 · 3 comments
Closed

.first throws an error if used with less than 2 values #26

renatoargh opened this issue Apr 12, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@renatoargh
Copy link

I have a dinamically set array of env variables which I pass to .first. Having this limitation makes me check for the length of the array and use .get if there is only a single element.

What is the reason behind this limitation? Is it something that we stop throwing this error, or at least make it configurable?

PS.: thanks for your awesome lib 👍

@nzakas nzakas added the enhancement New feature or request label Apr 12, 2021
@nzakas
Copy link
Contributor

nzakas commented Apr 12, 2021

Ah, that's an interesting use case I didn't consider. Yes, the idea was that if you were using first() with a single-item array, that it was probably an error and you should be alerted.

I can see an argument this case isn't important enough to throw an error because there is really no harm done with a one-item array. I'm not opposed to changing this behavior.

@renatoargh
Copy link
Author

If it is fine for you then I will try to come up with a PR soon (not sure when though). In the meanwhile I will keep my ifs :)

@nzakas
Copy link
Contributor

nzakas commented Apr 15, 2021

I'm on it. 👍

@nzakas nzakas closed this as completed in 6c8b62b Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants