Skip to content

Conversation

@nicholaslawton
Copy link
Contributor

String.drop is a safe version of String.skip, which intends to protect a call to String.skip with arguments which would cause an exception, and instead return an empty string.

However, the comparison of the length of the input string with the number of characters to drop is inverted. When it would be safe to drop the requested number of characters from the input string, String.drop will instead return an empty string; and when the requested number of characters exceeds the length of the input string, String.drop will cause the exception from String.skip.

The solution is to invert the comparison.

@gusty gusty merged commit 7e01134 into fsprojects:master Nov 27, 2020
@gusty
Copy link
Member

gusty commented Nov 27, 2020

Good catch, thanks

@Janiczek
Copy link

Ah, someone beat me to this 😄 I've just noticed this when solving AdventOfCode ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants