Friday, 6 September 2013

Return the first non empty/blank value?

Return the first non empty/blank value?

I have 2 bindings I'm calling path and callback.
What I am trying to do is to return the first non-empty one. In javascript
it would look like this:
var final = path || callback || "";
How do I do this in closure?
I was looking at the "some" function but I can't figure out how to combine
the compjure.string/blank check in it. I currently have this as a test,
which doesn't work. In this case, it should return nil I think.
(some (clojure.string/blank?) ["1" "2" "3"])
In this case, it should return 2
(some (clojure.string/blank?) ["" "2" "3"])
Thanks.

No comments:

Post a Comment