User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions

Translation code removal
(Translation code removal)
(Translation code removal)
Line 47:
AbuseFilter has support for non-associative arrays, which can be used like in the following examples.
 
{{Caution|1=<translate><!--T:460--> Expressions like <tvar|1><code>page_namespace in [14, 15]</code></> may not work as expected.</translate> <translate><!--T:440--> This one will evaluate to <tvar|1><samp>true</samp></> also if <tvar|2><code>page_namespace</code></> is <tvar|3><samp>1</samp></>, <tvar|4><samp>4</samp></>, or <tvar|5><samp>5</samp></>.</translate> <translate><!--T:441--> For more information and possible workarounds, please see <tvar|1>[[:phab:T181024|T181024]]</>.</translate>}}
 
<syntaxhighlight lang="c">
Line 53:
my_array[0] == 5
length(my_array) == 4
int( my_array ) === 4 // <translate><!--T:409--> Same as length</translate>
float( my_array ) === 4.0 // <translate><!--T:410--> Counts the elements</translate>
string(my_array) == "5\n6\n7\n10\n" //<translate><!--T:17--> Note: the last linebreak could be removed in the future</translate>
5 in my_array == true
'5' in my_array == true
'5\n6' in my_array == true //<translate><!--T:18--> Note: this is due to how arrays are casted to string, i.e. by imploding them with linebreaks</translate>
1 in my_array == true //<translate><!--T:19--> Note: this happens because 'in' casts arguments to strings, so the 1 is caught in '10' and returns true.</translate>
my_array[] := 57 // <translate><!--T:411--> This appends an element at the end of the array</translate>
my_array === [ 5, 6, 7, 10, 57 ]
my_array[2] := 42 // <translate><!--T:412--> And this is for changing an element in the array</translate>
my_array === [ 5, 6, 42, 10, 57 ]
</syntaxhighlight>
 
== Comments == <!--T:20-->
<translate>
== Comments == <!--T:20-->
 
<!--T:21-->
You can specify comments using the following syntax:
</translate>
/* <translate><!--T:22--> This is a comment</translate> */
 
/* <translate><!--T:22--> This is a comment</translate> */
<translate>
 
== Arithmetic == <!--T:23-->
 
<!--T:24-->
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>
222

edits