![]() Let’s say you had some configuration variables such as the following. Go is a general-purpose language designed with systems programming in mind. Iota - Go Programming Language Wiki Summary Gos iota identifier is used in const declarations to simplify definitions of incrementing numbers. ![]() It’s not just about the space though, especially with how powerful modern hardware is. ![]() If you have a group of 4, 10, or even 100 unique values, do you really need to store an entire string? An int will take up less room in your program’s memory. Why not just use strings for unique values? For example, const Head = "head" and const Shoulder = "shoulder"? □īesides the overlapping answer of the compiler not guaranteeing uniqueness, a string takes much more memory and can lead to performance issues under constrained circumstances. Find documentation on iotaledger / iota.go Public main 10 branches 29 tags Go to file muXxer Move chrysalis serializer to own go module ( 424) d9965e4 3 days ago 511 commits. Head, Shoulder, Knee, and Toe, have the same value. GitHub - iotaledger/iota.go: IOTA Go API Library. By using an enum, you’re ensured by the compiler that none of the constants in your group, e.g. Yes, you could do that, but enums are powerful by how they group sets of constants together and guarantee unique values. And if you want an integer constant, can’t you just use a normal const? E.g. 1 day ago &0183 &32 ÁWá (CC BY-SA 3.0) The lack of generics used to be the biggest challenge to using Go, according to the annual Go Developer Survey. At first, enums may not seem useful, but I can assure you they are. Let’s look at some questions you may have about enums. Type BodyPart int const ( Head BodyPart = iota // Head = 0
0 Comments
Leave a Reply. |