The following code returns nil:
(.setProperty (Properties.) "key1" "value1") -> nil
The following, however, seems to work as intended:
(doto (Properties.) (.setProperty "key1" "value1")) -> {"key1" "value1"}
Why is that?
.setProperty
returns the previous value, or null
if one did not exist. Since it is operating on a new Properties
instance, this is nil
. (doto x f)
evaluates f
with x
in the first argument position and then returns x
. In this case the nil
returned by setProperty
is ignored and the modified Properties
instance is returned.