Logo

Programming-Idioms

History of Idiom 169 > diff from v80 to v81

Edit summary for version 81 by programming-idioms.org:
[Ada] Sample value not needed

Version 80

2020-10-10, 21:21:22

Version 81

2020-11-06, 09:12:14

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.

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.

Variables
n,s
Variables
n,s
Extra Keywords
size characters chars number runes
Extra Keywords
size characters chars number runes
Code
s : String := "Hello World";
n : Integer := s'Length;
Code
n : Integer := s'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