Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7329
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Nicest equivalent to counted "for" loop? |
| Date | 2017-01-15 14:03 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <o5fvgc$1sov$1@gioia.aioe.org> (permalink) |
| References | <36c7832c-aad6-4003-ae76-c392fbe591b7@googlegroups.com> |
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
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar
Nicest equivalent to counted "for" loop? brec <sbrecher@gmail.com> - 2016-12-01 13:58 -0800
Re: Nicest equivalent to counted "for" loop? sbrecher@gmail.com - 2016-12-01 14:01 -0800
Re: Nicest equivalent to counted "for" loop? Robert Klemme <shortcutter@googlemail.com> - 2016-12-02 20:56 +0100
Re: Nicest equivalent to counted "for" loop? "Robert L." <No_spamming@noWhere_7073.org> - 2017-01-15 14:03 +0000
csiph-web