Logo

Programming-Idioms

History of Idiom 46 > diff from v49 to v50

Edit summary for version 50 by nsmryan:
Admin deletes impl 478: Wrong, a character may be multi-bytes

Version 49

2020-07-18, 20:56:41

Version 50

2020-07-18, 20:57:41

Idiom #46 Extract beginning of string (prefix)

Create string t consisting of the 5 first characters of string s.

Illustration

Idiom #46 Extract beginning of string (prefix)

Create string t consisting of the 5 first characters of string s.

Illustration
Variables
t,s
Variables
t,s
Code
let t = s[..5].to_string();