diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2009-08-18 16:27:29 -0400 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2009-08-18 16:27:29 -0400 |
commit | 3b6d95140393bf78930c9f4045ba2feab36f3946 (patch) | |
tree | 4cfe12c4a9faf95996912532a0118f40e15ee68e /src | |
parent | 8b360da5be1cac6612b3882037efa4c4c89ae643 (diff) |
str_utils2.clj: explain argument order of take/drop/butlast, refs #17
Diffstat (limited to 'src')
-rw-r--r-- | src/clojure/contrib/str_utils2.clj | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/clojure/contrib/str_utils2.clj b/src/clojure/contrib/str_utils2.clj index 25e03ad3..ec2741ce 100644 --- a/src/clojure/contrib/str_utils2.clj +++ b/src/clojure/contrib/str_utils2.clj @@ -104,7 +104,10 @@ (every? (fn [#^Character c] (Character/isWhitespace c)) s)) (defn take - "Take first n characters from s, up to the length of s." + "Take first n characters from s, up to the length of s. + + Note the argument order is the opposite of clojure.core/take; this + is to keep the string as the first argument for use with ->" [#^String s n] (if (< (count s) n) s @@ -112,14 +115,20 @@ (defn drop [#^String s n] "Drops first n characters from s. Returns an empty string if n is - greater than the length of s." + greater than the length of s. + + Note the argument order is the opposite of clojure.core/drop; this + is to keep the string as the first argument for use with ->" (if (< (count s) n) "" (.substring s n))) (defn butlast "Returns s without the last n characters. Returns an empty string - if n is greater than the length of s." + if n is greater than the length of s. + + Note the argument order is the opposite of clojure.core/butlast; + this is to keep the string as the first argument for use with ->" [#^String s n] (if (< (count s) n) "" |