Re: [go-nuts] strings and when to use them

2017-05-11 Thread Ilya Kostarev
On Wed, 10 May 2017 10:05:56 -0700 (PDT)
Zachary Kaplan  wrote:

> can somebody please explain to me when a function
> should to return a string as opposed to, say a []byte? thanks
> 
Just a few examples.
Strings can be keys in map[string]something, []byte can't be a key due
to them are non comparable.
You can loop over letters/rune in word with "for range string".  

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] strings and when to use them

2017-05-10 Thread Zachary Kaplan
in golang, strings are immutable. thus, if i want to modify a string in 
place, i'll need to cast or copy each element from the string to a similar 
but mutable data structure. this seems inefficient for simple command line 
programs that take input from stdin and access it through os.Args. can 
somebody please explain to me when a function should to return a string as 
opposed to, say a []byte? thanks

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.