Relevant documentation link for the uninitiated: https://docs.ruby-lang.org/en/master/syntax/control_expressi...
“The form of the flip-flop is an expression that indicates when the flip-flop turns on, .. (or ...), then an expression that indicates when the flip-flop will turn off. While the flip-flop is on it will continue to evaluate to true, and false when off.”
This is one of the few features of Ruby I've never found a use for, and not fit lack of trying.
I thought I remembered Matz once saying it would be removed, But I could be wrong. Maybe someone uses it.
It's from Awk, probably via Perl. https://www.gnu.org/software/gawk/manual/html_node/Ranges.ht...
Re:How it became like this? Ruby Range class
by pizza234 on Tuesday July 30, 2024 @02:33AM
(#41106559)
The flip-flop operator is very useful to extract continuous subsets, typically, sections of (multi-line) strings, where the dev defines the delimiters - think of the `=begin` and `=end` keywords.
I've personally never used for anything else than strings, but when I do, it's very useful.
Can you predict the output of the following?