Lambdas at Salesforce Apex

Does Apex support the lambda concept?

Ultimately, I'm trying to dry some really duplicate code in my tests, so I would like to be able to pass functions around, something like this (C # -esq)

public static TestMethod void some_test_method(){
  Arrange( ()=>
    // some setup stuff
  );
  Act( ()=>
    // test action
  );
  System.assertEquals(...);
}
+5
source share
1 answer

Apex does not have lambda. In fact, it does not have anonymous classes . (This would be your next question.) You will have to stick with the declared classes. Apex supports Java ish interfaces and abstract classes.

+10
source

All Articles