How to "delete" a key from NamedTuple

I know tuples are meant to be immutable, but I am interested in a way to create a new named tuple B that is the same as A except that it has :key1 deleted.

I was hoping something like this would work

B = delete(A, :key)

but it doesn’t.

1 Like
1 Like

Unless I misunderstand, delete didn’t work because there is no such function in Base.

Take a look at: GitHub - JeffreySarnoff/NamedTupleTools.jl: some utilities for working with NamedTuples

See Base.structdiff.

5 Likes