by jballanc · 2y ago · 0 comments
Can you predict the output of the following?
(1..20).each do |i|
puts i if i.odd?..i.prime?
endI thought I remembered Matz once saying it would be removed, But I could be wrong. Maybe someone uses it.
I've personally never used for anything else than strings, but when I do, it's very useful.
“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.”
(1..20).each do |i|
puts i if i.odd? || i.prime?
end
edit - upon testing, I just realized the parent's code prints 10 & 16, my code does not, so not the same.