Created
May 28, 2021 19:42
-
-
Save lostkagamine/2b3bbf35d5b10c19160291f9abfc72ba to your computer and use it in GitHub Desktop.
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
# untrustworthy_boolean.har | |
function make_untrustworthy!(obj) do | |
if type(obj) != "boolean" then | |
abort("not a bool") | |
end | |
override obj.get do | |
trueval = obj.get!() | |
if Harmony::Random.select(1, 5) == 1 then | |
trueval = not trueval | |
end | |
return trueval | |
end | |
end | |
mybool = true | |
make_untrustworthy!(mybool) | |
# mybool now has a 1/5th chance of lying about itself |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment