Skip to content

Instantly share code, notes, and snippets.

@lostkagamine
Created May 28, 2021 19:42
Show Gist options
  • Save lostkagamine/2b3bbf35d5b10c19160291f9abfc72ba to your computer and use it in GitHub Desktop.
Save lostkagamine/2b3bbf35d5b10c19160291f9abfc72ba to your computer and use it in GitHub Desktop.
# 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