Update java string methods to clojure functions

With Clojure 1.8.0 finally those string methods now have corresponding
Clojure functions.

Of note here is that the clojure.string/index-of function responds
with nil if nothing is found and not -1 as .IndexOf previously did.
This commit is contained in:
Damian Niemczyk 2016-01-25 21:30:57 +01:00 committed by Colin Jones
parent 52fe0cd615
commit a8fe71e26f
2 changed files with 5 additions and 5 deletions

View File

@ -24,7 +24,7 @@
"olleh"
"hello"
13
-1
nil
"hello world"
true
false

View File

@ -37,13 +37,13 @@
(= __ (string/reverse "hello"))
"Maybe you want to find the index of the first occurence of a substring"
(= 0 (.indexOf "hello world" __))
(= 0 (string/index-of "hello world" __))
"Or maybe the last index of the same"
(= __ (.lastIndexOf "hello world, hello" "hello"))
(= __ (string/last-index-of "hello world, hello" "hello"))
"But when something doesn't exist, it turns up negative"
(= __ (.indexOf "hello world" "bob"))
"But when something doesn't exist, nothing is found"
(= __ (string/index-of "hello world" "bob"))
"Sometimes you don't want whitespace cluttering the front and back"
(= __ (string/trim " \nhello world \t \n"))