You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These functions would return an Ok value with the prefix or suffix stripped, or an Error(Nil) value when the prefix or suffix does not exist in the string.
casestring.strip_prefix("https://gleam.run","https://"){Ok(site)->"found site "<>siteError(Nil)->"no site found"}// -> "found site gleam.run"
(I know this can be done with adding strings in pattern matching, but this would be useful in pipes and there is no way to handle strip_suffix with that approach)
You can already achieve this through combining string.starts_with and string.drop_start, but that's rather clunky and this feels much more gleam-y to me.
I find myself using them a decent amount when I write rust, and I noticed they're even used several times in the gleam compiler!
The text was updated successfully, but these errors were encountered:
These functions would return an Ok value with the prefix or suffix stripped, or an Error(Nil) value when the prefix or suffix does not exist in the string.
(I know this can be done with adding strings in pattern matching, but this would be useful in pipes and there is no way to handle strip_suffix with that approach)
You can already achieve this through combining
string.starts_with
andstring.drop_start
, but that's rather clunky and this feels much more gleam-y to me.I find myself using them a decent amount when I write rust, and I noticed they're even used several times in the gleam compiler!
The text was updated successfully, but these errors were encountered: