Hack: How to convert a keyset to a darray

Date: 2020-03-23 | 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);

Want more like this?

The best / easiest way to support my work is by subscribing for future updates and sharing with your network.