scala> varMONTH = 12; varDAY = 24 MONTH: Int = 12 DAY: Int = 24
scala> var (HOUR, MINUTE, SECOND) = (12, 0, 0) <console>:11: error: not found: value HOUR var (HOUR, MINUTE, SECOND) = (12, 0, 0) ^ <console>:11: error: not found: value MINUTE var (HOUR, MINUTE, SECOND) = (12, 0, 0) ^ <console>:11: error: not found: value SECOND var (HOUR, MINUTE, SECOND) = (12, 0, 0)
使用大写变量就会带来这个问题吗?怀着这个疑问,进行对照测试
1 2 3 4 5
scala> var (hour, minute, second) = (12, 0, 0) hour: Int = 12 minute: Int = 0 second: Int = 0
全小写变量,没问题。
1 2 3 4 5 6 7 8 9 10
scala> var (Hour, Minute, Second) = (12, 0, 0) <console>:11: error: not found: value Hour var (Hour, Minute, Second) = (12, 0, 0) ^ <console>:11: error: not found: value Minute var (Hour, Minute, Second) = (12, 0, 0) ^ <console>:11: error: not found: value Second var (Hour, Minute, Second) = (12, 0, 0)
首字母大写,报错。
1 2 3 4 5
scala> var (hOUR, mINUTE, sECOND) = (12, 0, 0) hOUR: Int = 12 mINUTE: Int = 0 sECOND: Int = 0