Hack: How to convert a keyset to a darray

Published: 2020-03-23 12:44:22 -0500 -0500

Reading time: 1 mins (76 words)

Tags: hack hacklang darray keyset

problem

I’ve been using a lot more hacklang at work and have run across many usecases that don’t have the greatest documentation. One such usecase is how to convert from a keyset to a darray. This is how I solved that.

solution

The darray actually has a pretty flexible constructor so you can create a darray from a keyset by simply passing the keyset into the darray.

For example:

$my_keyset = keyset['a', 'b'];
$my_darray = darray($my_keyset);

About the Ham

Hi I'm Hamilton and I wrote / built this! I like doing lots of things, but mostly I like to build (and then share those buildings). Some things I'm currently building: art, software, and prose. To stay up-to-date with my latest buildings, subscribe to my email list or follow one of my many other accounts. #buildit #shipit #justhamit

comments powered by Disqus