mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2026-03-01 04:28:51 +00:00
Add support to GetIntOrZero() #1276
Labels
No labels
I1
I2
I3
I4
S1
S2
S3
S4
U0
U1
U2
U3
U3
U4
blocked
bug
bug
cli
compiler
config
config
consensus
dependencies
discussion
documentation
enhancement
epic
feature
go
good first issue
help wanted
neotest
network
oracle
performance
question
rpc
security
smartcontract
task
task
task
test
vm
wallet
windows
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neo-go#1276
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lock9 on GitHub (Mar 21, 2024).
Is your feature request related to a problem? Please describe.
The following code will throw an 'Invalid Cast Exception' in runtime:
This is because it returns
nilwhen the key is not present.Describe the solution you'd like
I like how Neow3j solves this problem by exposing a GetIntOrZero method. As the name suggests, it will return
0if the key is not present.Reference:
neow3j/neow3j@f2b243a5a0/devpack/src/main/java/io/neow3j/devpack/Storage.java (L165)Describe alternatives you've considered
I'm checking for
nilbefore using it.Additional context
Casting will no longer be necessary with this improvement. Another change that could help, would be to allow
Getcalls without thecontextparameter.Don't forget to add labels!
enhancement@roman-khimov commented on GitHub (Apr 1, 2024):
Related to #3381, likely can even be replaced by it.