📜  红宝石 |字符串长度方法

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

红宝石 |字符串长度方法

length是 Ruby 中的 String 类方法,用于查找给定字符串的字符长度。

示例 1:

# Ruby program to demonstrate
# the length method
   
# Taking a string and
# using the method
puts "GFG".length
puts "geeksforgeeks".length

输出:

3
13

示例 2:

# Ruby program to demonstrate
# the length method
   
# Taking a string and
# using the method
puts "g4g".length
puts "ruby string".length

输出:

3
11