You need to sign in to do that
Don't have an account?
Error trying first example in the Apex language reference manual
I'm sure it's me, but...
On pages 27-29 of the Apex language reference manual, there is an example that creates a custom object (book_c and a custom field within the object Price_c). Then, a sample for loop within an apex class is demonstrated with the code below:
public class MyHelloWorld {
public static void applyDiscount(Book_c[] books){
for (Book_c b :books) {
b.Price_c *= 0.9;
}
}
}
However, when I try to build this code , I get the following error:
Error:Compile Error: Invalid type: Book_c at line 3 column 6
Like I said, I'm sure it's me but...why is this not working?
Thanks for any assistance
It is Book__c (two underscores)
All Answers
Correction - the custom object is called Book_c, not book_c
It is Book__c (two underscores)
Also make sure that you have created the Book custom object in the previous step.
Thank you both very much. The double underscore was my problem.