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
Subin009Subin009 

for loop trivial error Expecting '}' but was: 'for'

Hi Lately I am getting Expecting '}' but was: 'for' while saving for loop in apex.

Even a simple for loop counter is not working..Experiencing this today.

Please asssit.
Thanks
Subin Babu
Please see the code

public with sharing class sharedLocStockAdjust {
    for(Schema.Location temp : [select Id,Name from Location where LocationType='Van'])
    {
    }
}
ravi soniravi soni
hy subin,
try following code.
public with sharing class sharedLocStockAdjust {
    public static void localMethod(){
    for(Schema.Location temp : [select Id,Name from Location where LocationType='Van']){
        system.debug('temp : ' + temp);
    }
}
}
let me know if it helps you and don't forget to mark it as best answer.
Thank you
 
Subin009Subin009
Thank you ..That fixed it..forgot to add the function :) Appreciate your help.