User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions
Content added Content deleted
(Translation code removal) |
(Translation code removal) |
||
Line 47: | Line 47: | ||
AbuseFilter has support for non-associative arrays, which can be used like in the following examples. |
AbuseFilter has support for non-associative arrays, which can be used like in the following examples. |
||
{{Caution|1= |
{{Caution|1=Expressions like <code>page_namespace in [14, 15]</code> may not work as expected. This one will evaluate to <samp>true</samp> also if <code>page_namespace</code> is <samp>1</samp>, <samp>4</samp>, or <samp>5</samp>. For more information and possible workarounds, please see [[:phab:T181024|T181024]].}} |
||
<syntaxhighlight lang="c"> |
<syntaxhighlight lang="c"> |
||
Line 53: | Line 53: | ||
my_array[0] == 5 |
my_array[0] == 5 |
||
length(my_array) == 4 |
length(my_array) == 4 |
||
int( my_array ) === 4 // |
int( my_array ) === 4 // Same as length |
||
float( my_array ) === 4.0 // |
float( my_array ) === 4.0 // Counts the elements |
||
string(my_array) == "5\n6\n7\n10\n" // |
string(my_array) == "5\n6\n7\n10\n" // Note: the last linebreak could be removed in the future |
||
5 in my_array == true |
5 in my_array == true |
||
'5' in my_array == true |
'5' in my_array == true |
||
'5\n6' in my_array == true // |
'5\n6' in my_array == true // Note: this is due to how arrays are casted to string, i.e. by imploding them with linebreaks |
||
1 in my_array == true // |
1 in my_array == true // Note: this happens because 'in' casts arguments to strings, so the 1 is caught in '10' and returns true. |
||
my_array[] := 57 // |
my_array[] := 57 // This appends an element at the end of the array |
||
my_array === [ 5, 6, 7, 10, 57 ] |
my_array === [ 5, 6, 7, 10, 57 ] |
||
my_array[2] := 42 // |
my_array[2] := 42 // And this is for changing an element in the array |
||
my_array === [ 5, 6, 42, 10, 57 ] |
my_array === [ 5, 6, 42, 10, 57 ] |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
⚫ | |||
<translate> |
|||
⚫ | |||
<!--T:21--> |
|||
You can specify comments using the following syntax: |
You can specify comments using the following syntax: |
||
</translate> |
|||
⚫ | |||
⚫ | |||
<translate> |
|||
== Arithmetic == |
== Arithmetic == |
||
<!--T:24--> |
|||
You can use basic arithmetic symbols to do arithmetic on variables and literals with the following syntax: |
You can use basic arithmetic symbols to do arithmetic on variables and literals with the following syntax: |
||
</translate> |
|||
* <code>-</code> — <translate><!--T:25--> Subtract the right-hand operand from the left-hand operand.</translate> |
* <code>-</code> — <translate><!--T:25--> Subtract the right-hand operand from the left-hand operand.</translate> |