C
coolgeng coolgeng
[Note: parts of this message were removed to make it a legal post.]
Hi
I do not know how to explain the different result between the two
snippets:
First snippet:
def dial(digit)
puts digit end
digits = 0..9
puts digits.each {|digit| dial(digit) }
output:
0
1
2
3
4
5
6
7
8
9
0..9
Second snippet:
(0..9).each do |digit|
puts digit
end
output:
0
1
2
3
4
5
6
7
8
9
Why did the first snippet will generate the word like "0..9" at last line?
Hi
I do not know how to explain the different result between the two
snippets:
First snippet:
def dial(digit)
puts digit end
digits = 0..9
puts digits.each {|digit| dial(digit) }
output:
0
1
2
3
4
5
6
7
8
9
0..9
Second snippet:
(0..9).each do |digit|
puts digit
end
output:
0
1
2
3
4
5
6
7
8
9
Why did the first snippet will generate the word like "0..9" at last line?