dict get

Jan 10, 2012 at 4:13pm

dict get

Despite what it says in the help, when you send ‘get mykey’ to [dict mydict] you get the key and the value out of the second output (not just the value). Usually I don’t want to know the key so I have to loose it somehow, usually by using [route mykey].

I feel like there should be a better way to do this, is there?

#61147
Jan 10, 2012 at 4:30pm

That’s perfectly acceptable. You can also do “unpack s i” and get the second outlet. That would allow to have different keys and not worry about route.

#220373
Jan 10, 2012 at 6:09pm

True, but I still have to think about if I need [unpack s i], [unpack s f] etc.

taking the right output from [zl.slice 1] is the best I have come up with so far.

Shame you can’t pass the name of the dict an an argument to [dict] could easily make an abstraction then.

It is a silly small point but being able to do something like [dictutil mydict get mykey] and jut get the value would be ideal, 1 object not 3 much less visual noise in the patch.

The fact that dicts now exist at all is really great, so I will stop moaning and keep patching.

#220374
Jan 10, 2012 at 7:32pm

I usually put a message object with $2 or $2 $3 if the key contains another dict ;]

#220375
Jan 10, 2012 at 11:47pm

I’m using the following a fair bit as an abstraction:

– Pasted Max Patch, click to expand. –

same result as zl slice but might be handy to be able to route some other keys while you’re at it.

#220376

You must be logged in to reply to this topic.