What is the string upper-case method in Clojure?
Strings in Clojure
Strings in Clojure are a sequence of characters enclosed in double quotation marks ("").
String upper-case
The string upper-case method in Clojure converts all characters of a string to the upper case.
Syntax
(upper-case s)
Parameter
The string upper-case method accepts one parameter, which is the string s.
Return value
This method returns a string with all characters in the upper case.
Let’s see an example.
Example
(ns clojure.examples.hello(:gen-class))(defn EXAMPLE [](println (clojure.string/upper-case "Educative"))(println (clojure.string/upper-case "educative")))(EXAMPLE)
Explanation
-
Line 3: We define a function
EXAMPLE. -
Line 4: We convert the string
EducativetoEDUCATIVEusing the stringupper-casemethod. We nestclojure.stringusing the dot notation. This shows that theupper-casemethod is a core string method of Clojure. -
Line 5: We convert
educativetoEDUCATIVEusing the same method as in line 4. -
Line 6: We call the
EXAMPLEfunction.