Ruby/String/String.new
Материал из Wiki.crossplatform.ru
Содержание |
Creating Strings
You can create strings with the new method. title = String.new # => ""
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
test a string to see if it is empty before you process it
title = String.new # => "" title.length [or] title.size # => 0
test a string to see if it is empty with empty?
title = String.new # => "" title.empty? # => true
The new method can take a string argument
title = String.new # => "" title = String.new( "Much Ado about Nothing" ) title = String.new # => "" title.empty? # => false title.length # => 22