SharpScript. Remove Key from Dictionary

How to remove a key from dictionary in SharpScript?

I tried following code:

```code
sample = {} |> end
sample.myKey = 1 |> end
sample |> removeKeyFromDictionary('myKey') |> end
sample |> dump
sample |> removeKeyFromDictionary('myKey') |> to => sample
sample |> dump
```

Whose output is:

{
myKey: 1
}
{
myKey: 1
}

I was expecting it to be:

{}
{}

Thanks

Using a single string key is a bug resolved in this commit, in the meantime you can use an array of keys in both removeKeyFromDictionary or remove, e.g:

sample |> remove(['myKey'])

FYI instead of ending everyline in a code-block you can use a quiet modifier to mute the entire code block then emit anything you need outside of the block, e.g:

```code|q
sample = {}
sample.myKey = 1
sample |> remove(['myKey'])
```
{{ sample |> dump }}
1 Like