Skip to content

Instantly share code, notes, and snippets.

@brianmfear
Created April 26, 2021 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmfear/e2f3e54130eb97d754b586cc8960f772 to your computer and use it in GitHub Desktop.
Save brianmfear/e2f3e54130eb97d754b586cc8960f772 to your computer and use it in GitHub Desktop.
q341460 example class v1
public class q341460 {
public String property {
get;
set;
} {
property = 'Default Property Value';
}
public final String finalProperty {
get;
set { finalProperty = value; }
} {
finalProperty = 'Default Final Property Value';
}
public static void demo() {
q341460 instance = new q341460();
instance.finalProperty = 'New Final Property Value'; // compile error: Final members can only be assigned in their declaration, init blocks, or constructors: finalProperty
System.debug('instance.property access getter ' + instance.finalProperty ); // 'New Final Property Value'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment