Ruby | String end_with? Method
Last Updated :
12 Dec, 2019
end_with? is a String class method in Ruby which is used to check if the specified string ends with one of the suffixes given or not.
Syntax: str.end_with?
Parameters: Here, str is the given string.
Returns: true if it matches otherwise return false.
Example 1:
puts "Ruby" .end_with?( "by" )
puts "String" .end_with?( "ab" )
|
Output:
true
false
Example 2:
puts "Sample" .end_with?( "ple" , "sam" )
puts "Program" .end_with?( "gr" , "pro" )
|
Output:
true
false
Share your thoughts in the comments
Please Login to comment...