Hello,

2009/3/10 Jason Wolfe <jawo...@berkeley.edu>

>
> > (let [person (get-the-person)]
> >   (when-not (nil? person)
> >     (let [address (.getAddress person)]
> >       (when-not (nil? address)
> >          (let [street (.getStreet address)]
> >             (when-not (nil? street)
> >                (do-something-finally-with-street street)))))
> >
>
>
> ?-> sounds potentially useful to me, but let me also point out that
> you could simplify the above to:
>
> (when-let [person (get-the-person)]
>  (when-let [address (.getAddress person)]
>    (when-let [street (.getStreet address)]
>       (do-something-finally-with-street street))))
>

No, because here, you could also short-circuit on the value false , and not
only nil.
And it's definitely what I had in a first attempt, and wanted to avoid :
having to think about variable names and add several nested levels of lets.


>
> Not quite
>
> (?-> (get-the-person) #(.getAddress %) #(.getStreet %) do-something)
>
> but it's halfway there at least.
>
> Info on contributing is here:
>
> http://clojure.org/contributing
>
> The first step is to get your CA signed and in the mail.
>

Yes you're right, I already have sent my CA, and will re-read this page.

But I thought that before proposing something (even for clojure-contrib), it
would be interesting to see if what I would like to propose sounds
interesting to more than one person :-) and if somebody having commit rights
on clojure-contrib informally accepts the contrib, before creating an issue
with the patch attached ?


>
> Thanks,
> Jason
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to