Structs with reference fields #18541
Answered
by
Yaisis
felixf4xu
asked this question in
Questions and Answers
Replies: 1 comment
-
struct Node {
a ?&Node
b ?&Node
}
n := Node{}
c := n.a or { ... } |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
felixf4xu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm reading the document of https://github.com/vlang/v/blob/master/doc/docs.md#structs-with-reference-fields, it says
I'm fine with the language design, but I'd like to ask what's the suggested solution if I can't use nil to initialize a reference in a structure?
I don't like the
unsafe
keyword here, if I'm writing a purelyv
code withoutc
interop, the word ofunsafe
should be avoided as much as possible, from language design point of view.What will be the designed solution in the future?
Beta Was this translation helpful? Give feedback.
All reactions