Logo

Programming-Idioms

  • Clojure
  • Elixir

Idiom #97 Check string suffix

Set boolean b to true if string s ends with string suffix, false otherwise.

Are the last characters of s equal to this suffix?
b = String.ends_with?(s, suffix)
(require '[clojure.string :as str])
(let [b (str/ends-with? s suffix)]
   ; ...  
 )
return suffix.size() == s.size() - s.rfind(suffix);

New implementation...