[#66678] [ruby-trunk - Feature #10481] Add "if" and "unless" clauses to rescue statements — alex@...
Issue #10481 has been updated by Alex Boyd.
3 messages
2014/12/04
[#66762] Re: [ruby-changes:36667] normal:r48748 (trunk): struct: avoid all O(n) behavior on access — Tanaka Akira <akr@...>
2014-12-10 0:44 GMT+09:00 normal <ko1@atdot.net>:
3 messages
2014/12/10
[#66851] [ruby-trunk - Feature #10585] struct: speedup struct.attr = v for first 10 attributes and struct[:attr] for big structs — funny.falcon@...
Issue #10585 has been updated by Yura Sokolov.
3 messages
2014/12/15
[#67126] Ruby 2.2.0 Released — "NARUSE, Yui" <naruse@...>
We are pleased to announce the release of Ruby 2.2.0.
8 messages
2014/12/25
[#67128] Re: Ruby 2.2.0 Released
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2014/12/25
I can't install it in any of our Ubuntu servers using rbenv:
[#67129] Re: Ruby 2.2.0 Released
— SHIBATA Hiroshi <shibata.hiroshi@...>
2014/12/25
> I can't install it in any of our Ubuntu servers using rbenv:
[ruby-core:67248] [ruby-trunk - Feature #10498] Make `loop` yield a counter
From:
duerst@...
Date:
2014-12-31 06:29:12 UTC
List:
ruby-core #67248
Issue #10498 has been updated by Martin D端rst.
Assignee changed from ruby-core to Yukihiro Matsumoto
----------------------------------------
Feature #10498: Make `loop` yield a counter
https://bugs.ruby-lang.org/issues/10498#change-50719
* Author: Franck Verrot
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: current: 2.2.0
----------------------------------------
# Problem
Teaching Ruby, we always end up with that type of construct
```ruby
i = 0
loop do
i += 1
# do something with i....
raise StopIteration if i ...
end
```
# Solution
What I propose with this patch is making `loop` yield the iteration count:
```ruby
loop do |i|
# do something with i....
raise StopIteration if i ...
end
```
`i` starts at 0 and stops at `FIXNUM_MAX` (there's no `Float::Infinity` equivalent for integers).
# Alternate solution
`Integer#times` could work if we had an `<Integer's infinity>` object, so we would just do `<Integer's Infinity>.times { |i| ... }`.
Also, this is the very first patch I submit to Ruby, I might have done something horrible, feel free to tell me :-)
---Files--------------------------------
0001-vm_eval.c-loop-now-yields-a-incremented-counter.patch (1.74 KB)
0001-vm_eval.c-loop-now-yields-a-incremented-counter.patch (1.86 KB)
--
https://bugs.ruby-lang.org/