fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 168: Trim suffix
Idiom # 168: Trim suffix
See
programming-idioms.org
:
Code
t := if s.ends_with p s.substring 0 s.byte_length-p.byte_length else s
What are effects?
Running Example
ex168 is doit(s, p String) => t := if s.ends_with p s.substring 0 s.byte_length-p.byte_length else s say t doit "Mah Nà Mah Nà Do doo be-do-do" "Mah Nà " doit "Mah Nà Mah Nà Do doo be-do-do" "be-do-do" doit "Mah Nà Mah Nà Do doo be-do-do" "Do doo be-do-do"
What are effects?
last changed: 2024-07-01
next: Idiom # 169: String length