eneon
April 26, 2006, 9:34am
1
Hi
In irb i wrote 3.time(puts “dsds”) and it doesn’t work why?
Here i pasted log:
irb(main):027:0> 3.times(puts “Hello!”)
(irb):27: warning: parenthesize argument(s) for future version
Hello!
ArgumentError: wrong number of arguments (1 for 0)
from (irb):27:in `times’
from (irb):27
eneon
April 26, 2006, 9:46am
2
You don’t have a block:
3.times { puts “dsds” }
eneon
April 26, 2006, 9:46am
5
Hi,
And how about this ?
irb(main):005:0> 3.times { puts(“Hello!”) }
Hello!
Hello!
Hello!
=> 3
–
Martins
eneon
April 26, 2006, 7:58pm
6
On Apr 26, 2006, at 12:48 PM, Mohammad wrote:
isn’t easier just to wright
number.times do
puts “whatever”
end
i find this alot better then blocking it
do … end is also a block. Just another way to write it.
James Edward G. II
eneon
April 26, 2006, 7:48pm
7
isn’t easier just to wright
number.times do
puts “whatever”
end
i find this alot better then blocking it
eneon
April 27, 2006, 8:13am
8
Mohammad wrote:
isn’t easier just to wright
number.times do
puts “whatever”
end
i find this alot better then blocking it
Yes, i like do…end more than {} blocks, too