Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would just accept the hash, I think a lot of us prefer it to the pseudo keyword args.

    (defn message [text {:keys [style color]}] ...)
    (message "Text" {:style :bold :color :red})
To the person asking, that {:keys [style color]} is destructuring, it's not required, but it's nice, it's equivalent to doing:

    (defn message [text opts]
       (let [style (:style opts)
             color (:color opts)]
          ...))


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: