How do I use hash map indexing without try blocks

How do I use a "function that raises in a context that cannot raise" if I know for sure it won't raise, for example in hash map indexing
3 Replies
benny
benny11mo ago
your best option is to simply mark the calling function as raising. the ability to raise comes from a key not existing, which is technically possible and leads to errors. Alternatively you could code your own wrapped struct around dict that allows unsafe access or an optional return (since collections.optional is now available)
ModularBot
ModularBot11mo ago
Congrats @benny, you just advanced to level 4!
Boluwatifẹ
BoluwatifẹOP11mo ago
Optional works for me (using the find method), thanks
Want results from more Discord servers?
Add your server