Excerpts from Gergely Kontra's mail of 19 Sep 2005 (CDT): > Is there a similar construct to python's: > > >>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... I don't think there's a direct idiom. I'd write this in Ruby as: (2...10).each do |n| fac = (2...n).find { |x| n % x == 0 } if fac puts "#{n} equals #{fac} * #{n / fac}" else puts "#{n} is a prime number" end end This is much clearer IMO. -- William <wmorgan-ruby-talk / masanjin.net>