#Getting the hang of the `Optional`
1 messages · Page 1 of 1 (latest)
Agree, major kudos to @wild drum, every time I wanted to do something with Optional there was already a method or helper function (like Opt()) in place. Needs successfully anticipated 😎
❤️ yay nice to hear it!
out of curiosity, have you ever found yourself wanting to get an unset optional? to fallback to the default?
i was thinking of adding OptEmpty or similar 🤔
Possibly yeah, so far I've just ended up passing the same as the default there https://github.com/kpenfound/greetings-api/blob/zenith/ci/backend/main.go#L50
Contribute to kpenfound/greetings-api development by creating an account on GitHub.
but if I had more than just 1 optional there I could see that getting unwieldy and there's some downsides of duplicating definitions of defaults
I also love the pattern. My only pain so far has been the lack of Optional[[]string]
agh, you're right, that's a neat find - it shouldn't be hard to add support for it
This allows making slice types ([]any) optional, which is permitted at the API level, but wasn't allowed at the type constraint level.
We previously used this constraint because it was assumed ...