In Ruby how do I generate a long string of repeated text?

前端 未结 2 1543
别那么骄傲
别那么骄傲 2021-01-31 12:59

What is the best way to generate a long string quickly in ruby? This works, but is very slow:

str = \"\"
length = 100000
(1..length).each {|i| str += \"0\"}
         


        
2条回答
提交回复
热议问题