Closed christophaigner closed 5 years ago
You are god damn right for constant usage 👍 . In this tip, we were given an example of static property usage. Also, we share this tip on Twitter, Instagram, and Telegram, therefore; we cannot edit these posts. To sum up, you can add a new tip about the "best practice of constant usage". 💯
We should update the old commit using this pr. The problem is we shared images already. What should we do for them? Remove? :/
@emreozdil @alicanbatur you decide. In my opinion it'd be better to remove the old images, since the way it is written currently is just not ideal.
In general it's not a big deal to use type properties on structs, it's more about the specific example, because you don't want anyone to create instances of this Constant
value type.
Description
Replacing the struct here with an enum gives one benefit: You cannot create instances of an enum, if it doesn't have a case inside. So you cannot write
let myConstants = Constants()
if you use an enum, but you can do so if you use a struct and this is something that you should avoid. Another option would be to make the init of this struct private, which is less convenient.