parameter type of strings.NewReplacer

69 views
Skip to first unread message

nadashin

unread,
Jul 5, 2021, 7:00:20 PM7/5/21
to golan...@googlegroups.com
What is the purpose of having,

func NewReplacer(oldnew ...string) *Replacer

instead of,

func NewReplacer(oldnew ...[2]string) *Replacer

Ian Lance Taylor

unread,
Jul 5, 2021, 7:07:48 PM7/5/21
to nadashin, golan...@googlegroups.com
It's easier to both write and read
r := strings.NewReplacer("old1", "new1", "old2", "new2")
than
r := strings.NewReplacer([2]string{"old1", "new1"},
[2]string{"old2", "new2"})

Ian
Reply all
Reply to author
Forward
0 new messages