method Flag.on
Is the flag on for p? Deterministic: the same principal always gets the same answer for the same rules.
Example:
fn main() io {
let half = Flag.percent(50)
var on = 0
for i in 0..1000 {
let p = Principal.User("user{i}", [], Map.new(), false, none)
if half.on(r#for: p) { on += 1 }
}
print("about half: {on > 400 && on < 600}")
}Output
about half: true
pub(api) fn on(r#for: &Principal) -> boolComplexity. O(1).
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
r#for: &Principal | |
Returns
bool
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/dynconf.oxl:810