X.times dont work

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

You don’t have a block:
3.times { puts “dsds” }

Dawid Skomski wrote:

    from (irb):27


3.times{ puts “Hello!”}

13 wrote:

Hi,

And how about this ?

irb(main):005:0> 3.times { puts(“Hello!”) }
Hello!
Hello!
Hello!
=> 3


Martins

Im thankful you :slight_smile:

Hi,

And how about this ?

irb(main):005:0> 3.times { puts(“Hello!”) }
Hello!
Hello!
Hello!
=> 3


Martins

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

isn’t easier just to wright
number.times do
puts “whatever”
end
i find this alot better then blocking it

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 :slight_smile: