Skip to content

re: Real applications of flip-flop in ruby VIEW POST

re: Nicely done, Mudsie! I especially like the code you provide, which makes the definition unambiguous. You might elaborate " is treated as flip...

Hi Cary, nice to see you here!

I did not elaborate “it’s treated as ff inside conditionals only” mostly because it’s written everywhere in docs and I’d like the reader who’s indeed curious to go read docs instead of / after this luring intro.

Also, if the reader does not go REPL to play with it, trying if i.odd?..i.odd? and if i.odd?...i.odd? and all that, this writing is not for that reader :)


I suggested showing if i.odd?..i.odd? as well as if i.odd?..i.even? because several descriptions of the operator (including Bekal's) don't cover the case where the switch-on condition is the same as the switch-off condition.

code of conduct - report abuse