Project

General

Profile

Actions

Feature #6073

closed

Proposal of extending syntax of for loop

Added by shouichi (Shouichi Kamiya) about 12 years ago. Updated about 12 years ago.

Status:
Rejected
Target version:
-
[ruby-core:42851]

Description

Hi,

I propose to extend syntax of for loop which allows us to write multiple loop with guard easily.
This extension is inspired by Scala. Here is a example

for i in 1..4 when i % 2 == 0
j in 5..8 when j % 4 == 0
puts "#{i}, #{j}"
end

Above code is same as following code.

for i in 1..4
if i % 2 == 0
for j in 5..8
if j % 4 == 0
puts "#{i}, #{j}"
end
end
end
end

I already implemented this syntax and attached a patch.
What do you think about this syntax guys?

Thank you,
Shouichi


Files

0001-extend-for-loop-syntax.patch (6.45 KB) 0001-extend-for-loop-syntax.patch shouichi (Shouichi Kamiya), 02/24/2012 02:19 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0