Article View: pl.comp.lang.ruby
Article #215Re: iteracja po tablicy kazdy z kazdym "ruby-way"
From: Marcin Mielżyński
Date: Mon, 02 Oct 2006 20:51
Date: Mon, 02 Oct 2006 20:51
34 lines
1304 bytes
1304 bytes
można jeszcze:
class Array
def each_pair
each_with_index do |a,i|
i.next.upto(size-1) do |j|
yield a,self[j]
end
end
end
end
i mniej wydajna
class Array
def each_pair
each_with_index do |a,i|
self[i.next..-1].each do |b|
yield a,b
end
end
end
end
lopex
Technical Details
Message-ID:
<efru3v$er4$1@news.onet.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mailReferences:
<op.tgs6t3unhwe0a4@negative-361apc>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail From: Marcin Mielżyński <lopx@gazeta.pl> Newsgroups: pl.comp.lang.ruby Subject: Re: iteracja po tablicy kazdy z kazdym "ruby-way" Date: Mon, 02 Oct 2006 22:51:09 +0200 Organization: Onet.pl Lines: 34 Message-ID: <efru3v$er4$1@news.onet.pl> References: <op.tgs6t3unhwe0a4@negative-361apc> NNTP-Posting-Host: chello087207016023.chello.pl Mime-Version: 1.0 X-Trace: news.onet.pl 1159822271 15204 87.207.16.23 (2 Oct 2006 20:51:11 GMT) X-Complaints-To: usenet@news.onet.pl NNTP-Posting-Date: Mon, 2 Oct 2006 20:51:11 +0000 (UTC) X-Sender: 5Da2qcG7AWj7WISFX859Php/OS6q4VnB In-Reply-To: <op.tgs6t3unhwe0a4@negative-361apc> User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit