Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

setindex doesn't seem to work as advertised #40

Open
tcovert opened this issue Jul 14, 2017 · 1 comment
Open

setindex doesn't seem to work as advertised #40

tcovert opened this issue Jul 14, 2017 · 1 comment

Comments

@tcovert
Copy link

tcovert commented Jul 14, 2017

julia> using NamedTuples

julia> NamedTuples.setindex(@NT(a=1, b=2), :b, "cde")
(a = 1, b = 2)

I would have thought the result would be (a = 1, b = "cde")

@nalimilan
Copy link
Member

Confirmed. The docstring says: "Create a new NamedTuple with the new value set on it, either overwriting the old value or appending a new value." But the implementation uses merge which (as documented) takes the LHS. It would make sense to use the RHS instead since that's how merge works in general, and how NamedTuple is going to be implemented in Base. Also setindex isn't very useful if it doesn't overwrite existing values.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants