I am trying to make a global byte array from a string with:
var operators = []byte {"+-*/%"}
however, I am getting the error
cannot use string("+-*/") (type untyped string) as type byte in array or slice literal
What am I doing wrong here?
I am trying to make a global byte array from a string with:
var operators = []byte {"+-*/%"}
however, I am getting the error
cannot use string("+-*/") (type untyped string) as type byte in array or slice literal
What am I doing wrong here?
Use a type conversion to convert a string to a slice of bytes. Note the use of ()
instead of {}
.
var operators = []byte("+-*/%")
The code in the question is a composite literal.