From: Dossy Date: 2002-09-02T01:28:48+09:00 Subject: Re: Ruby aesthetic I can't tell who originally wrote this, but: > >>I'll conclude with one (new) feature from Python that makes me green with > >>envy: list comprehensions. For those who don't know what that means, > >>here's an example: > >> > >>Ruby: squares_less_than_10 = numbers.find_all{|i| i<10}.map{|i| i^2} > >> > >>Python: squares_less_than_10 = [x^2 for x in numbers if x < 10] What about this in Ruby, instead: squares_less_than_10 = numbers.collect { |x| x**2 if x < 10 } - [nil] -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)