daniu54 / earie-treasures

A 2d top-down loot-em-up with horror and stealth elements
0 stars 0 forks source link

Try out CSharpFunctionalExtensions Result Type for handling unset values from godot editor in C# #87

Closed Abb4 closed 1 year ago

Abb4 commented 1 year ago

Sometimes I have code where I would like to set a property from editor, and if it is not set, use some logic to set it. If that fails too, throw an exception. As far as I know the official C# Export docs do not provide a method to check if a [Export] value is null. You just get a NullReference exception, when you use it.

But everyone hates null reference exceptions. An elegant(?) solution would be to use a Result type, like in rust. I found vkhorikov/CSharpFunctionalExtensions which implements some of the Result Type, as I want it.

It would be cool to implement the Node Extension functions as Result Types.