length and size methods both return an integer indicating how many characters a string holds. : String.new « String « Ruby






length and size methods both return an integer indicating how many characters a string holds.


title = String.new # => ""
title = String.new( "Much Ado about Nothing" )

title = String.new # => ""
title.empty? # => false
title.length # => 22

 








Related examples in the same category

1.Creating Strings
2.test a string to see if it is empty with empty?
3.test a string to see if it is empty before you process it
4.The new method can take a string argument