#Best way to handle structure with different data

1 messages · Page 1 of 1 (latest)

red tinsel
#

I'm adding a bunch of different actions to a queue which will then need to be processed. Each action will have different data which it comes with.
My initial thoughts on how to do this would be a pointer to whatever data structure necessary through a struct, I can determine what structure that is via the action enum and cast appropriately.

Is there a better, cleaner way to do it than this though?

const ActionInfo = {
  action: Action,
  value: Pointer // Will point to a different structure depending on the action
}

const Action = enum {
  ...
}
dull olive
#

if you know all the different types