在我的程序中,我想为字符串中的双字母添加一个方法。我的问题是有一个公共方法吗?例如:
'The'
→TThhee'
这是我所拥有的:
puts "Please enter text: "
input = gets
letters = input.chomp.to_s
puts "You entered: " + letters + "."
list_letters = letters.split(//)
list = list_letters.join(". ")* 2.to_i
puts "Your text is made up of the letters: " + list + "."