[RUBY] About the length method

length method

** A method that a string has. The length method is a method that counts the number of characters in a string. Spaces between characters are also counted. ** **

The use of methods Execute by connecting the method name "length" with dot. </ Font> for the value as shown below.

[Example] irb

#Output the number of characters in the string
irb(main):001:0> "Hello World".length
=> 11

"Hello World" .length can also be viewed as a single expression. In the above example, what is displayed after => is the number of characters "11" of "Hello World". The character itself is "10" characters, but it will be "11" characters including "" spaces.

Let's run the following code in irb

Now, let's actually try the length method.


#Output the number of characters with the length method
irb(main):001:0> "good morning".length

#If it continues to be displayed like this, it is successful
=> 12


** A method is a collection of some processing in programming. The length method is a method that counts the number of characters in a character string. ⚠︎ Blanks (spaces) are also counted. ** **

that's all.

Recommended Posts

About the length method
About the method
Output about the method # 2
About the authenticate method.
About the map method
About the ancestors method
About the to_s method.
Output about the method Part 1
about the where method (rails)
Consideration about the times method
About the role of the initialize method
About the package
About No Method Error
About the StringBuilder class
Commentary: About the interface
About the asset pipeline
About Java method binding
About the ternary operator
About method splitting (Java)
About the Kernel module
[Output] About the database
About the [ruby] operator
About the handling of Null
About specifying the JAXRS path
Note the StringUtils # containsAny method
What is the pluck method?
A note about the scope
About the description of Docker-compose.yml
[Java Silver] About equals method
Understand the helper method form_with
About the same and equivalent
About the Android life cycle
About the explanation about functional type
About the programming language Crystal
About Rails scraping method Mechanize
What is the initialize method?
How to use the link_to method
About the behavior of ruby Hash # ==
About the language to be learned
How to use the include? method
How to use the form_with method
About the basics of Android development
[Rails] About the Punk List function
About the equals () and hashcode () methods
About the symbol <%%> in Rails erb
About the information sharing app band
Java comparison using the compareTo () method
About the current development environment (Java 8)
I tried to explain the method
A murmur about the utility class
[Rails] About helper method form_with [Basic]
Think about the 7 rules of Optional
About =
[Rails 6] destroy using the resources method
Was that so, the user_signed_in? method
Summary about the introduction of Device
About the log level of java.util.logging.Logger
Call the super method in Java
About the continuous division method learned in the 4th grade of elementary school
My thoughts on the equals method (Java)