Hi Rhialto,
Keys in Clojure don't have to be keywords - a map can contain strings
and symbols as keys so the first shorthand {:keys [fred ethel lucy]}
works when the keys in your map are keywords (which is the default
because keys are usually keywords in Clojure). But if your map
happens to use strings or symbols for the keys that's when the other
directives would be used (:strs, :syms).
Examples:
user=> ;;EXAMPLE 1 - map contains keyword as key
(let [ {:keys [fred ethel lucy]} {:fred "value of fred key"}] (print
fred))
value of fred keynil
user=> ;;EXAMPLE 2 - map contains string as keyword so :strs directive
is used
(let [ {:strs [fred ethel lucy]} {"fred" "FRED"}] (print fred))
FREDnil
user=> ;;EXAMPLE 3 - map contains string as keyword but :keys
directive is used so it doesn't work as expected
(let [ {:keys [fred ethel lucy]} {"fred" "FRED"}] (print fred))
nilnil
Hope that helps,
Paul