10

As I know Apex is a combination of Java and C# languages (maybe this list should contain more languages).

Speaking about System.runAs, documentation says that it is a method. It looks like it is a static method of System class. But how can then we send written code in block of this method?

System.runAs(u){
    //any lines of code are here
}

Normally we can't pass code lines to method, so it doesn't look like method. So we can't call System.runAs as "method". I didn't find something relevant in Java. Is it an anonymous method, implementation of some interface with anonymous class? Is it something specific only for Apex ?

What is a name of construction System.runAs(u){} ?

1 Answer 1

5

EDIT: In C# they're just called "statements". See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement

5
  • 1
    thanks for answer, but I know for what is it using. My question is about what is a proper name of System.runAs(u) {} construction. Commented Nov 30, 2017 at 10:53
  • Ah sorry. I missunderstood - thought you asked how to use it. In C# they're just called statements (docs.microsoft.com/en-us/dotnet/csharp/language-reference/…)
    – Christoph
    Commented Nov 30, 2017 at 11:05
  • 1
    can you update your answer with it? Commented Nov 30, 2017 at 11:12
  • Sure. I've added it above the "runAs" explanation
    – Christoph
    Commented Nov 30, 2017 at 11:17
  • 1
    They're called statements in Python too. This functionality is similar to how the with keyword works.
    – Adrian Larson
    Commented Nov 30, 2017 at 14:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .