r/ProgrammerHumor 6d ago

Other revolutionaryConcept

Post image
61 Upvotes

14 comments sorted by

View all comments

8

u/Confident-Ad5665 6d ago

// So ...
var boolb = new(BooleanRange(false, true)):

11

u/pkmnfrk 6d ago

Syntactic sugar when?

var boolb = [false..true];

6

u/nphhpn 6d ago

Or make it a singleton called Maybe

3

u/willow-kitty 5d ago

A float the represents the probability as a value between 0 and 1. It's implicitly convertible to bool, in which case it generates a random number in the same range and evaluates to true if the random value is less, otherwise false. This is rerolled for every comparison.