-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Un-idiomatic introduction of update
#34
Comments
Agreed. What about: (update {:count 1} :count inc)
;=> {:count 2}
(update {:words "hello"} :words str ", world")
;=> {:words "hello, world"} and:
IIRC Indeed I wonder if it's the scope for re-use that makes the need for (-> {:count 0}
(update :count inc)
(update :count inc)
(update :count inc)
(update :count inc)
(update :count inc))
;=> {:count 5} |
Totally agreed. That's why rather than provide better examples, I think we should remove |
Yeah good idea. It will likely arise in the (potentially confusingly named) |
I like that approach a lot. |
In outline/data_structures.md, the section on updating maps is not idiomatic Clojure:
This is all technically true, but extremely misleading. A reasonable person would expect
hello
to then be the "updated" version returned fromupdate
, but it's not. Not only is this not explained, but it's weird and unnecessary todef
a name thenupdate
it anyway. This is a major trap for newcomers to write non-idiomatic Clojure, yet we're explicitly teaching it!We even say the word "save"!
The text was updated successfully, but these errors were encountered: