• vinaysharma_jpr
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Can an inner class access an instance variable of its outer class?

 

 

I have a bit of code which, simplified, looks like this. In context, it produces the error " Method does not exist or incorrect signature" on line 8, but for some reason this simplified version produces the error "User-defined type not allowed here" on line 4.

 

The apex manual says "Inner classes can have instance member variables like outer classes, but there is no implicit pointer to an instance of the outer class (using the this

keyword)." (link)

 

 

 

 


1: public class MyClass {
2: public Map<String,Statistical_Datum__c> dataMap;
3:
4: public class Datum {
5: Statistical_Datum__c datumObject;
6:
7: public Datum( String statistic ) {
8: datumObject = dataMap.get( statistic );
9: }
10: }
11: }