📜  红宝石 |字符串 delete_suffix 方法

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

红宝石 |字符串 delete_suffix 方法

delete_suffix是 Ruby 中的 String 类方法,用于返回给定字符串的副本,其中删除了尾随后缀。

示例 1:

# Ruby program to demonstrate 
# the delete_suffix method 
       
# Taking a string and 
# using the method
puts "Ruby".delete_suffix("by")
puts "Class".delete_suffix("s")

输出:

Ru
Clas

示例 2:

# Ruby program to demonstrate 
# the delete_suffix method 
       
# Taking a string and 
# using the method
puts "Sample".delete_suffix("pl")
puts "Input".delete_suffix("ut")

输出:

Sample
Inp