Logo

Programming-Idioms

History of Idiom 46 > diff from v20 to v21

Edit summary for version 21 by :
New Go implementation by user [ufm]

Version 20

2015-10-29, 14:05:14

Version 21

2015-11-14, 22:04:58

Idiom #46 Extract beginning of string (prefix)

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

Idiom #46 Extract beginning of string (prefix)

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

Code
t := string([]rune(s)[:5])
Doc URL
https://golang.org/ref/spec#Conversions
Demo URL
http://play.golang.org/p/AFkuQnah0q