doc: string immutability example
							parent
							
								
									f7a77f4041
								
							
						
					
					
						commit
						01b28ef1a5
					
				|  | @ -355,7 +355,14 @@ println(s) // "hello world" | |||
| 
 | ||||
| In V, a string is a read-only array of bytes. String data is encoded using UTF-8. | ||||
| 
 | ||||
| Strings are immutable. | ||||
| Just like in Go and Java, strings are immutable, which means their values cannot be changed. | ||||
| 
 | ||||
| The following code will raise an error: | ||||
| 
 | ||||
| ```v | ||||
| mut s := 'hello' | ||||
| s[0] = `H` | ||||
| ``` | ||||
| 
 | ||||
| Both single and double quotes can be used to denote strings. For consistency, | ||||
| `vfmt` converts double quotes to single quotes unless the string contains a single quote character. | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue