On Oct 16, 4:29 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Oct 15, 11:47 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
>
>
>
> > 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 "h
On Oct 16, 2008, at 7:29 AM, Rich Hickey wrote:
> Another semantic marker here is 'do'. do in Clojure implies side-
> effects. Since you can't uppercase a string by side effect, doto isn't
> the right tool for this job.
Neat.
I explored the "do..." marker a little with Clojure:
- user
On Oct 15, 11:47 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> 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))
Thanks!
--~--~-~--~~~---~--~~
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,
Hi,
On 16 Okt., 08:17, Timothy Pratley <[EMAIL PROTECTED]> wrote:
> What does 'mix in non-methods' means? I read the (doc ->) but I really
> don't follow that explination.
-> is more general than .. . .. only works on objects.
(.. foo (bar baz) (frob nicate))
is equivalent to
(. (. foo ba
Oh wow, powerful syntax!
> user=> (-> "hello" .toUpperCase (.replace "H" "J"))
> "JELLO"
> .. would also work, but I pretty much always prefer -> because you can
> mix in non-methods, and the methods are clearly indicated with a
> leading dot. In fact, I could imagine lobbying to have .. remove
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
On Wed, Oct 15, 2008 at 11:20 PM, Parth Malwankar
<[EMAIL PROTECTED]> wrote:
>
> 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.S
Calling a java method on a string directly works.
user=> (.toUpperCase "hello")
"HELLO"
user=> (class "hello")
#=java.lang.String
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=> (cla