仓颉编程报错

对不可变变量赋值,就会报错

error: cannot assign to immutable value
==> a.cj:8:20:
| 
8 |  case 77 => a = 'a77'
|  ^^^^^^^^^ 
| 
note: variable 'a' is immutable
==> a.cj:5:9:
| 
5 |  let a = 'Hello World!'//不可变量
|  ^ 
| 

error: cannot assign to immutable value
==> a.cj:10:20:
| 
10 |  case 78 => a = 'a78'
|  ^^^^^^^^^ 
| 
note: variable 'a' is immutable
==> a.cj:5:9:
| 
5 |  let a = 'Hello World!'//不可变量
|  ^ 
| 

error: cannot assign to immutable value
==> a.cj:12:19:
| 
12 |  case _ => a= ''
|  ^^^^^ 
| 
note: variable 'a' is immutable
==> a.cj:5:9:
| 
5 |  let a = 'Hello World!'//不可变量
|  ^ 
| 

3 errors generated, 3 errors printed.

posted @ 2024-07-28 22:30  txwtech  阅读(9)  评论(0编辑  收藏  举报