2019-01-04

Trailhead commonly asked questions: Expecting '}' but was: 'for'

網頁上的程式碼怎麼原樣貼上去,還沒有過?
Why the code can't be save while it's been directly copied and pasted from the Trailhead page?

通常這個問題產生的原因,是因為你把程式碼直接貼在class內,但這種「把內臟攤出來」的做法是不被允許的。
This usually happened due to 'directly paste code inside class', you need to put the logic inside a method.

仔細看一下 trailhead 提供的程式碼,應該是包在 method 內的。
Look the Trailhead page, carefully, the logic should be inside of a method.

你是不是直接沒有複製到 method 的頭尾XD?
There are probably some code that your missing. :P

p.s. 請善用右上角的copy // Use the copy in the up-right corner


沒有留言:

張貼留言

Check for typo before sending