doc: add missing word in union section (#24926)

This commit is contained in:
JalonSolov 2025-07-19 02:17:06 -04:00 committed by GitHub
parent 6dad361eb7
commit ae9a69bdf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2867,12 +2867,12 @@ automatically modifies all the rest. The largest union member defines the size o
One reason, as stated above, is to use less memory for storing things. Since the size of a union
is the size of the largest field in it, and the size of a struct is the size of all the fields in
struct added together, a union is definitely better for lower memory usage. As long as you only
need one of the fields to be valid at any time, the union wins.
the struct added together, a union is definitely better for lower memory usage. As long as you
only need one of the fields to be valid at any time, the union wins.
Another reason is to allow easier access to parts of a field. For example, without using a union,
if you want to look at each of the bytes of a 32-bit integer separately, you'll need bitwise
RIGHT-SHIFTs and AND operations. With a union, you can access the individual bytes directly.
`RIGHT-SHIFT`s and `AND` operations. With a union, you can access the individual bytes directly.
```v
union ThirtyTwo {
a u32
@ -8397,4 +8397,4 @@ This is the place to be, to discuss the V language, learn about latest
developments, quickly get help with issues, witness/participate in
~~epic flame wars~~ constructive criticism exchanges and design decisions.
Join it, and learn more about languages, games, editors, people, Klingons,
Conway's law and the universe.
Conway's law and the universe.