Ruby/String/multiply strings

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Содержание

print one word three times, then add or append more text with +

puts "Hello, " * 3 + "Matz!"



What if you want to print out a line of text three times?

puts "Hello, Matz! " * 3



you can multiply strings

puts "abc" * 5



You cannot multiply two strings

puts "12" + 12
puts "2" * "5"
# <TypeError: can"t convert Fixnum into String>