Skip to main content

Syntax of on new trigger

1 reply [Last post]
Joined: 2005-08-17

How should new trigger be defined with new version?

older syntax as follows does not work:

trigger on new X {
insert [3,4] into this.nums;

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-10

New triggers are no longer part of the language. For most cases, specify the initial value when the attribute is declared; your example would look like this:

[pre]attribute nums: Integer[] = [3, 4];[/pre]

If code needs to be executed after all attributes have been initialized, you can use a postinit block:

[pre]postinit {
System.out.println("my object has been created: {this}");