specialChars = "]%#$!_.+?~&[*/^;@"
puts(specialChars[16])
Run Code Online (Sandbox Code Playgroud)
打印一个空行.为什么会这样?我需要逃避一些角色吗?
# 是用">分隔时用于字符串插值的保留字符:
# Example
puts "My name is #{my_name}!"
Run Code Online (Sandbox Code Playgroud)
如果使用''而不是"",则禁用字符串插值,您可以正常使用它:
# The "" has been replaced with ''
specialChars = ']%#$!_.+?~&[*/^;@'
puts specialChars[16]
# => '@'
Run Code Online (Sandbox Code Playgroud)