Hi, working on a UEFN project here. I came across an odd behavior when doing mutations to a map object.
I was following one of the posted snippets as reference,
if (set ExampleMap["b"] = 3, ValueOfB := ExampleMap["b"]):
Print("Updated key b in ExampleMap to {ValueOfB}")
And notice that after running the game, this did not appear to work when I did an inversion of logic:
if (not (set ExampleMap["b"] = 3)):
Print("Could not update key b!")
The warning that there was failure to set B did not go off, but interestingly, the value did not get set within the map as well.
My theory on why this happens is that “not” evaluates the context given by setting a value within the map, and since it was not a “successful failure”, it considers it a failure context and rolls back the changes made. Looking at the documentation listed here, I believe that suspicion is correct, if I’m interpreting this right.
In this example, I don’t particularly care in terms of adding logic for when the expression succeeds, but I do care to add some when it fails.
I could always write it so that there’s an empty if statement and an else statement within the same block, but I find that is a bit less succinct than I’d hoped for. Is there a way to achieve this inversion without having to do it this way or we out of luck in this regard?
If we are out of luck, is there plans to change the language in the future before reaching a wider audience? If so, could it be possible to add an inversion without necessarily making it a failure context? Something like a traditional !(set ExampleMap["b"] = 3)
?