📜  红宝石 |字符串 chr 方法

📅  最后修改于: 2022-05-13 01:55:37.044000             🧑  作者: Mango

红宝石 |字符串 chr 方法

chr是 Ruby 中的 String 类方法,用于返回字符串开头的单字符字符串。

示例 1:

# Ruby program to demonstrate 
# the chr method 
       
# Taking a string and 
# using the method 
puts "Ruby".chr
puts "Method".chr

输出:

R
M

示例 2:

# Ruby program to demonstrate 
# the chr method 
       
# Taking a string and 
# using the method 
puts "String".chr
puts "Class".chr

输出:

S
C