What are the benefits of built_value enums over normal enums from the language

1,246

Solution 1

Mostly that they can easily be de/serialized from/to JSON.

Darts built-in enums are quite a bad fit where serialization is needed.

Solution 2

Serialization is one thing; the other major one is that they are proper classes: you can add code to them, and they can implement interfaces.

In this way they're much like Java's enums.

Share:
1,246
swissonid
Author by

swissonid

Updated on December 05, 2022

Comments

  • swissonid
    swissonid over 1 year

    In the built_value lib I found the example how to make enums. So I'm a bit confused. Because I do not see right away what are the benefits of useing the built_value enums. Does some one know it? What do I overlook?