I am completely lost in pattern matching for records
rec = { one: 1 two : 2 }
when rec is
{one _ , .. } -> # do something when one field is present in record
{} -> in any other record
Obviously it does not work this way, how to accomplish the task ?
Records are not what you want here. They do not have variable numbers of fields. Try using Dict, which has a function to get its size.
You won't be able to pattern match on Dict but you can get
keys. Dict entries are unordered though. If you want them to be ordered then you need a List of key value pairs.
@Artur Swiderski we're trying to make an example for what you needed in this situation (with a Dict), is this example good?
@Anton I already solved the problem but yes exactly what I wanted
Last updated: Jul 06 2025 at 12:14 UTC