Home > Articles > Programming > Ruby

📄 Contents

  • Print
  • + Share This
This chapter is from the book

2.4 Finding the Length of a String

The method length can be used to find a string's length. A synonym is size.

str1 = "Carl"
x = str1.length     # 4
str2 = "Doyle"
x = str2.size       # 5
  • + Share This
  • 🔖 Save To Your Account