Path: csiph.com!aioe.org!.POSTED!not-for-mail From: "Robert L." Newsgroups: comp.lang.ruby Subject: Re: Nicest equivalent to counted "for" loop? Date: Sun, 15 Jan 2017 14:03:57 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 20 Message-ID: References: <36c7832c-aad6-4003-ae76-c392fbe591b7@googlegroups.com> NNTP-Posting-Host: BJ7/mJrfCYDUqwfeZtvPAw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Complaints-To: abuse@aioe.org User-Agent: XanaNews/1.18.1.6 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.ruby:7329 On 12/1/2016, brec wrote: > Currently I've got... > > $Count = 192 # some arbitrary constant, or command line argument, or input; > 0 > > $i = $Count > while (i -= 1) >= 0 > # some stuff > end > > ...In other languages I'd use a counted "for" > loop. Is there something more elegant than the above? 3.downto(0){|i| p i} 3 2 1 0