From: Tamara Temple Date: 2013-06-12T10:23:06+09:00 Subject: Re: Loop with range question Scott H. wrote: > i=0 > loop do > i+=1 > next if i== 3..6 > print "#{i} " > break if i==10 > end > > expected => 1 2 7 8 9 10 > actual => warning: integer literal in conditional range > (don’t understand, thought it was telling me it does not work because it > can’t transform the range on the fly to the actual integers 3,4,5,6) Clippy sez: "It appears you are trying to use the flip-flop operator." Flip-flop is a bit odd, but this should work: i=0 loop do i+=1 next if i==3 .. i==6 # note the range is the comparisons print "#{i} " break if i==10 end output: ======= 1 2 7 8 9 10 a (possibly) more idiomatic way to write that would be: 1.upto(10) do |i| next if i==3 .. i==6 print "#{i} " end Still another, perhaps more useful: 1.upto(10).select{|i| true unless i==3 .. i==6 } which just returns the collection, suitable for other uses besides printing. Or, just use the #include? on the subranges as others have suggested.