Ruby| String Clear Method
Last Updated :
13 Dec, 2019
clear is a String class method in Ruby which is used to make the string empty.
Syntax: str.clear
Parameters: Here, str is the given string.
Return : An empty string.
Example 1:
puts "String" .clear
puts "Class" .clear
|
Output:
Example 2:
puts "" .clear
puts "Ruby" .clear
|
Output:
Share your thoughts in the comments
Please Login to comment...