Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
Newtype Index Pattern in Zig
(
matklad.github.io
)
4 points
by
birdculture
4 days ago
|
hide
|
past
|
favorite
|
3 comments
ThierryBuilds
4 days ago
[–]
Nice Article. However I fail to understand how using the enum prevents the usage of the wrong index in a data structure. Can you explain further?
reply
hiccuphippo
1 day ago
|
parent
[–]
I guess you would need to cast the index to the enum or you get a type error, which should narrow down the possible error locations.
reply
ThierryBuilds
20 hours ago
|
root
|
parent
[–]
Thanks for your response. Wouldn't using the `_` in the enums somehow make almost all integers index "cartable" to the enums?
reply
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
reply