Logo

Programming-Idioms

History of Idiom 169 > diff from v70 to v71

Edit summary for version 71 by thethanlaw:
[Ada] I messed up the assignment operator. Rookie move.

Version 70

2019-09-28, 03:35:34

Version 71

2019-09-28, 03:36:39

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration
Extra Keywords
size characters chars number runes
Extra Keywords
size characters chars number runes
Code
s : String := "Hello World";
n : Integer : s'Length;
Code
s : String := "Hello World";
n : Integer := s'Length;
Comments bubble
Easy! Just use the 'Length attribute of the String type.

Note that strings are not variable length.
Comments bubble
Easy! Just use the 'Length attribute of the String type.

Note that strings are not variable length.
Doc URL
https://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-3-6-3.html
Doc URL
https://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-3-6-3.html