1: user=> (def some-account {:number :any-number :balance :any-balance :bank :any-bank})
2: #'user/some-account
3: user=> (contains? some-account :bank)
4: true
5: user=> (assoc some-account :owner :any-owner)
6: {:owner :any-owner, :number :any-number, :balance :any-balance, :bank :any-bank}
7: user=> (contains? some-account :owner)
8: false
9: user=> (def some-account (assoc some-account :owner :any-owner))
10: #'user/some-account
11: user=> (contains? some-account :owner)
12: true
13: user=> (dissoc some-account :owner)
14: {:number :any-number, :balance :any-balance, :bank :any-bank}
15: user=> (contains? some-account :owner)
16: true
Can anyone explain this code?
Why, after (assoc some-account :owner :any-owner)
, does (contains? some-account :owner)
return false
?
Why, only after (def some-account (assoc some-account :owner :any-owner))
does (contains? some-account :owner)
return true
?
Why, after (dissoc some-account :owner)
, does (contains? some-account :owner)
returns true
?
I tried saying (def some-account (assoc some-account :owner :any-owner))
out of instinct. But why does it work this way?