this post was submitted on 17 Nov 2024
24 points (100.0% liked)
Factorio
1023 readers
38 users here now
A Lemmy community for the game Factorio made by Wube Software.
Rules
- Be a good person
- Content must relate to Factorio
- Adhere to Lemmy's Code of Conduct
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You can think of it that way - sure. If you want a deeper insight into development I'd just consider it a form of conditional switching. I think back to washing ores in SeaBlock (you're running recipes that could output one of like six things and sushi-ing is the only real recourse). Some filters might be dealing with success cases, some might be error cases - they aren't really treated any different at a basic level. The data needs to go where it's supposed to and exceptions (excepting unhandled ones) aren't really any different than any other status response.
Many operations can return multiple states, a "correct" usage of that operation is being able to handle all of those states in a reasonable and planned manner.
I feel like it's more analogous to enum pattern. Your belt is just a array, and your items are enums that may be part of that enum
So to go back to gleba, nutrient belts are just
Vec<Result<Nutriment, Spoilage>>