Created
February 22, 2012 10:13
-
-
Save shouichi/1883963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case # Empty! | |
when cond1 | |
do_something | |
when cond2 | |
do_another_thing | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in 1..4 when i % 2 == 0 | |
j in 5..8 when j % 4 == 0 | |
puts "#{i}, #{j}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = 0 | |
[1,2,3].each do |i| | |
end | |
p i #=> 0 | |
for i in [1,2,3] | |
end | |
p i #=> 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
primary : k_for | |
loops | |
k_end | |
{ | |
$$ = $2; | |
} | |
loops : for_var keyword_in expr_value | |
keyword_when expr_value term | |
compstmt | |
{ | |
scope = NEW_NODE(NODE_SCOPE, | |
table, NEW_IF(cond($5), $7, 0), args); | |
$$ = NEW_FOR(0, $3, scope); | |
} | |
| for_var keyword_in expr_value | |
keyword_when expr_value term | |
loops | |
{ | |
// 上と同じ。 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment