Logo

Programming-Idioms

  • Go
  • Python
  • Ruby

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 = s.end_with?(suffix)
import "strings"
b := strings.HasSuffix(s, suffix)
b = s.endswith(suffix)
(require '[clojure.string :as str])
(let [b (str/ends-with? s suffix)]
   ; ...  
 )

New implementation...