Mani
Mani

Reputation: 13

`*': String can't be coerced into Fixnum (TypeError)

i am trying with some basics.

space = " "
puts "Some Text: "
count = gets.chomp.to_i
print "#{count}" * space
print "*"

when i trying to run this it shows this error `*': String can't be coerced into Fixnum (TypeError)

Upvotes: 0

Views: 698

Answers (1)

Ursus
Ursus

Reputation: 30056

I think you wanted something like this

space = " "
puts "Some Text: "
count = gets.chomp.to_i
puts space * count
puts "*"

and use the form string * fixnum to repeat a string count times

Upvotes: 1

Related Questions