How to loop a string without `times` in Ruby -
i'm trying use loop
print "¡ruby!"
30 times. done 30.times{print "¡ruby!"}
, or using while
learning loop
. here code:
word = "¡ruby!" loop print word * 30 break if word.count < 30 end
after printing 30 times wanted,i errors:
"wrong number of arguments (at least 1)", "invalid multibyte char (utf-8) (syntaxerror)" , "syntax error, unexpected tfid, expecting end-of-input word = "�ruby!""
thanks.
i = 0 loop print "¡ruby!" += 1 break if > 29 end
this print
out string 30 times.
=> ¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!¡ruby!
for more legible output change print
puts
Comments
Post a Comment