You're viewing version 1.2.0 of trim. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (trim s)
Removes whitespace from both ends of string.

1 Example top

  • ;; Trim basically does what you'd expect.  What the doc string
    ;; does not tell you however is that:
    ;;  - null will cause an error
    ;;  - non-string parameters will be converted to a string
    ;;    before being trimed.
    
    (use 'clojure.string)
    user=> (trim "     a      ")
    "a"
    user=> (trim nil)  
    java.lang.NullPointerException (NO_SOURCE_FILE:0)
    user=> (trim 1.1)
    "1.1"
    user=> (trim [1 2 3])
    "[1 2 3]"
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/string.clj:184 top

(defn ^String trim
  "Removes whitespace from both ends of string."
  {:added "1.2"}
  [^CharSequence s]
  (.. s toString trim))
Vars in clojure.string/trim: .. defn
Used in 0 other vars

Comments top

No comments for trim. Log in to add a comment.