RTFM ;) <quote>
The *local* scope contains variables which only exist during the invocation of the current function, object or apply statement. *Local* variables can be declared using the var keyword: function multiply(a, b) { var temp = a * b return temp } Each time the multiply function is invoked a new temp variable is used which is in no way related to previous invocations of the function. When setting a variable which has not previously been declared as local using the var keyword the *this* scope is used. The *this* scope refers to the current object which the function or object/apply statement operates on. object Host "localhost" { check_interval = 5m } In this example the this scope refers to the *localhost* object. The check_interval attribute is set for this particular host. You can explicitly access the *this* scope using the this keyword: object Host "localhost" { var check_interval = 5m /* This explicitly specifies that the attribute should be set * for the host, if we had omitted `this.` the (poorly named) * local variable `check_interval` would have been modified instead. */ this.check_interval = 1m } Similarly the keywords *locals* and *globals* are available to access the local and global scope. <----------------------------- !!!!! </quote> Source: <https://www.icinga.com/docs/icinga2/latest/doc/17-language-reference/> - Chapter "Variable Scopes". Gruss Kai >>> On 22.11.2017 at 18:59, Tobias Koeck <tobias.ko...@gmail.com> wrote: > Hi, > > what is the difference between > > var varname = 1 > > and > > locals.varname = 1 > > And when use one and the other? > > Greetings > Tobias _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users