# Output "I love Ruby"
say = "I love Ruby"
puts say
# Output "I *LOVE* RUBY"
say['love'] = "*love*"
puts say.upcase
# Output "I *love* Ruby"
# five times
5.times { puts say }
本文通过三个简单的Ruby编程实例展示了字符串操作的基本用法,包括字符串赋值、修改与输出,为初学者提供了快速上手的实战案例。
# Output "I love Ruby"
say = "I love Ruby"
puts say
# Output "I *LOVE* RUBY"
say['love'] = "*love*"
puts say.upcase
# Output "I *love* Ruby"
# five times
5.times { puts say }
3456
1909

被折叠的 条评论
为什么被折叠?