Monday, December 16, 2013

the difference between get and find

‘find’ returns the entry of a map
‘get’ returns the value of a map
NOTE: get can be tricky when working with ‘nil’, as
(get {:ethel nil} :lucy)
;= nil
(get {:ethel nil} :ethel)
;= nil

in this case, ‘find’ is a better choice
(find {:ethel nil} :lucy)
;= nil
(find {:ethel nil} :ethel)
;= [:ethel nil]

No comments:

Post a Comment