-
Hi,sorry to bother you. I'm new to Golang and try to learn the language through your code. I notice that when using values in a struct, like
the code defined a method
to return it instead of directly using |
Beta Was this translation helpful? Give feedback.
Answered by
johningve
Feb 22, 2022
Replies: 1 comment 1 reply
-
Hi! There are a few reasons to do this in Go:
As for |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Hang95
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
There are a few reasons to do this in Go:
As for
Block.Hash()
, the main reason is to make the hash field immutable. Also, theHash()
method was previously used to calculate the hash the first time it was called, but I moved that toNewBlock
.