1. 追加一个字符串到一个字符串 << 操作符
2. join 方法可以直接从数组转换为字符
test_array=[1,2,3,4]
test_array << "hello"
puts test_array.join
结果输出: 1234hello
数组的join("insert_string") 方法,只是在中间插入, 不在最后插入
test_array.join("test")
=> "1test2test3test4testhello"
3. 变量和字符串关系
不是字符串,就用to_s方法
4. 插入字符串
template='here is example for insert string %s in string'
template % 'test_test'
=>"here is example for insert string [color=red]test_test[/color] in string"
2. join 方法可以直接从数组转换为字符
test_array=[1,2,3,4]
test_array << "hello"
puts test_array.join
结果输出: 1234hello
数组的join("insert_string") 方法,只是在中间插入, 不在最后插入
test_array.join("test")
=> "1test2test3test4testhello"
3. 变量和字符串关系
不是字符串,就用to_s方法
4. 插入字符串
template='here is example for insert string %s in string'
template % 'test_test'
=>"here is example for insert string [color=red]test_test[/color] in string"
105

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



