I write a code it keeps saying "compilation error" what should I do | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I write a code it keeps saying "compilation error" what should I do

Learn to code

16th Oct 2019, 9:47 PM
scansq
scansq - avatar
6 Answers
+ 6
Where is your code? With incomplete information how we would know that what problem you are facing.
16th Oct 2019, 10:11 PM
A͢J
A͢J - avatar
+ 6
If you opt for the HonFu technique, there is a way to reduce the complexity of that method from O(n) to O(log(n)) by commenting out half the code first. If it now compiles, the error was in the commented half so you can uncomment half of that half and retry. On the other hand, if it still did not compile, then the error was in the uncommented half, so you can apply the commenting trick to that half and retry 😂. This becomes more tedious if there is more than one compilation error.
17th Oct 2019, 3:01 AM
Sonic
Sonic - avatar
+ 5
~ swim ~ believe it or not, many years ago I have tried HonFu's technique.
17th Oct 2019, 2:55 AM
Sonic
Sonic - avatar
+ 5
Remember that if you are using a language that uses curly braces to denote scope {}, if you comment out one of them (e.g. starting brace, you also need to comment out the corresponding ending brace etc.)
17th Oct 2019, 3:05 AM
Sonic
Sonic - avatar
+ 5
While all this can be a bit silly, the error message from the compiler usually indicates which line the problem is in. That way you can go straight to the problem area O(k). Unfortunately SL code playground error messages don't help here.
17th Oct 2019, 3:07 AM
Sonic
Sonic - avatar
+ 4
Comment out your code except the first line. If it works, add the second line. If it works... and so on.
16th Oct 2019, 11:37 PM
HonFu
HonFu - avatar