forked from biased-unit/planout-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle nil values on indexing operations
Hitting a nil value previously would cause a crash in the experiment run. This happens in both the case of the value being in a map, and in the case where the value is part of a struct. This fix causes the code to instead return a nil. Unfortunately this is not quite ideal in the case of maps to numerical values. In a normal go map, maps with numerical values apparently return a 0 when the requested key is not present. There doesn't seem to be any simple way to maintain parity with that behavior (though it does seem kind of odd, looking at it from Java colored glasses), so a concession is made to just return a nil in that case.
- Loading branch information
1 parent
0a63106
commit c60a1c7
Showing
4 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"op": "set", | ||
"var": "nil", | ||
"value": { | ||
"op": "index", | ||
"base": { | ||
"op": "get", | ||
"var": "struct" | ||
}, | ||
"index": "None" | ||
} | ||
} |