Ruby | String delete_suffix Method
Last Updated :
03 Mar, 2023
delete_suffix is a String class method in Ruby which is used to return a a copy of the given string with trailing suffix deleted.
Syntax: str.delete_suffix Parameters: Here, str is the given string. Returns: A copy of the given string with trailing suffix deleted.
Example 1:
Ruby
puts "Ruby".delete_suffix("by")
puts " Class ".delete_suffix("s")
|
Output:
Ru
Class
Example 2:
Ruby
puts "Sample".delete_suffix("pl")
puts "Input".delete_suffix("ut")
|
Output:
Sample
Inp
Share your thoughts in the comments
Please Login to comment...