function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lee_CampbellLee_Campbell 

Unexpected "unexpected token" error

Hi all,

 

I'm writing a class that performs some simple arithmetic based on opportunity probabilities to get the average probability of all that owner/account/product's opportunities. My class takes some IDs and strings, and I want it to create lists based on these input arguments, but keep getting the "unexpected token" error. Here's a snippet of the code:

 

public class ForecastFunction {
	public static double getProbability(ID own, ID acc, String product, String division){
    	double estimate = 0;
        List<Opportunity> a = [select Probability from Opportunity where OwnerID := own];
        for(integer i = 0;i<a.size();i++){
            estimate+=a[i].Probability/a.size();
        }
        return estimate;
    }
}

 Where "own" is my unexpected token (both with and without the colon). What am I doing wrong? This should be bread and butter, but that error is crippling, and, to me, unobvious.

 

Any help you can offer would be great.

 

Thanks,

Lee

Best Answer chosen by Admin (Salesforce Developers) 
Lee_CampbellLee_Campbell

Oh my word... colon wrong side of equals sign.

 

Moron.

All Answers

Lee_CampbellLee_Campbell

Oh my word... colon wrong side of equals sign.

 

Moron.

This was selected as the best answer
SLockardSLockard

Swith the equal sign and colon so it's =: