CSBiology / FSharpAux

Auxiliary functions and data structures for the F# programming language
MIT License
23 stars 16 forks source link

[BUG] `String.first` and `String.last` raise `IndexOutOfRangeException` when applied to empty strings #21

Closed omaus closed 2 years ago

omaus commented 2 years ago

Description

String.first and String.last return IndexOutOfRangeException when applied to empty strings. It would be better to instead check for empty strings and throw an explicit error message.

Repro steps

Please provide the steps required to reproduce the problem

  1. Write
    String.first ""
    String.last ""
  2. Execute

Expected behavior

Proper error message.

Actual behavior

System.IndexOutOfRangeException.