> Am 31.01.2010 um 18:29 schrieb Daniel Werner: >> If I understand this arity version of get-in correctly, won't the >> default also be used if the value stored in the nested data structure >> evaluates to something false-y?
Thanks for spotting that early! On 1 February 2010 05:46, Meikel Brandmeyer <m...@kotka.de> wrote: > (if-let [l (reduce get m (pop ks))] > (get l (peek ks) not-found) > not-found)) Good idea, but peek and pop work differently on vectors and sequences, seeing get-in is not constrained to use vectors this could lead to an unexpected behavior: user=> (def m {:a 1, :b 2, :c {:d 3, :e 4}, :f nil}) #'user/m user=> (get-in3 m '(:c :e) 2) ;peek-pop keys applied in unexpected order 2 user=> (get-in2 m '(:c :e) 2) ;expected result 4 I've replaced the patch on assembla with this: (reduce #(get %1 %2 not-found) m ks))) And added test cases for the falsey returns and seq args Regards, Tim. -- 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 Note that posts from new members are moderated - please be patient with your first post. 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