词条 | Module:Range/doc |
释义 | Returns one function called "iswitch", which takes its inspiration from {{#switch, but is limited to numeric values, and allows for ranges. usage: syntax: {{#invoke:Range | iswitch | value = <Number> | ( <Ranges> = Result | )... [default=Result] }}
Result ::= any string (can be multiline) that does not contain | or }} (if needed, use {{tlf|!}}, and {{t|))}}. ) When a range begins with (, it means the value has to be larger than the left limit. otherwise, it can be equal to the left limit. For convenience, [ can be used to mark "larger or equal", but it's not required (i.e. "1..100" is the same as "[1..100" Similarly, when a range ends with ) it means the value has to be strictly less than the right limit. A range may begin or end with ".." Such that ..100 means "100 or smaller", and 60.. means "60 or larger". "..100)" means smaller than 100, and "(60.." means larger than 60 if value matches a ranges, the function will return the "Result" of one of the matching ranges. If more than one range matches, it is unpredictable which of the results will be returned. The function does not test for overlap. if none of the ranges match, and there is a "default", this value will return. otherwise, the function will return an empty string. For tests see Range/testcases |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。