Hi Parth,

> But if I do this in a doto, it doesn't seem to work but
> I don't get any error message.
>
> user=> (doto (new java.lang.String "hello") (toUpperCase))
> "hello"
> user=> (class (new java.lang.String))
> #=java.lang.String
>
> Shouldn't this be working? If this is (by design) because strings are
> immutable (so no doto) shouldn't there be an error message?
>
> What am I missing here.

"doto" operates on an object and returns the object that it operated  
on. In your case, it's the original string that gets returned. Strings  
are immutable so the toUpperCase call created a new string which was  
then thrown away.

The "->" operator will accomplish what you're looking for here. It  
returns the result of the operations, each result becoming the input  
for the next::

user=> (-> (String. "hello") .toUpperCase)
"HELLO"

--Steve


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to