From: "David A. Black" Date: 2009-02-10T23:00:24+09:00 Subject: Re: a better way to do this job? --1926193751-386037779-1234274477=:31275 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-386037779-1234274477=:31275" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-386037779-1234274477=:31275 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Tue, 10 Feb 2009, Tom Link wrote: >> � �ruby -e 'a = [:a,:b,:c]; b = []; while true; b << a[0,3]; end' > > That's a little bit unfair though. If you pushed an infinite number of > object of whatever class, you'd eventually run out of memory. I'm just making the point that even though two arrays may contain the same objects (not copies), arrays are not cost-free, so creating intermediate arrays may well be an issue. > I personally find #first() rather confusing (BTW [1,2,3].first > (3).class => Array). Yes, that's right -- I've over-enumeratored my response :-) David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management! --1926193751-386037779-1234274477=:31275-- --1926193751-386037779-1234274477=:31275--