Price fraction: Difference between revisions
Content added Content deleted
(→{{header|Dart}}: Add Dart implementation, add pre style) |
Langurmonkey (talk | contribs) |
||
Line 3,237: | Line 3,237: | ||
<syntaxhighlight lang="langur"># using an implied parameter .f ... |
<syntaxhighlight lang="langur"># using an implied parameter .f ... |
||
val .pricefrac = f |
val .pricefrac = f switch[and] .f { |
||
case >= 0.00, < 0.06: 0.10 |
case >= 0.00, < 0.06: 0.10 |
||
case >= 0.06, < 0.11: 0.18 |
case >= 0.06, < 0.11: 0.18 |
||
Line 3,259: | Line 3,259: | ||
case >= 0.96, <= 1.00: 1.00 |
case >= 0.96, <= 1.00: 1.00 |
||
default: throw "bad data" |
default: throw "bad data" |
||
# The default operator between test cases is "and". |
|||
# That is, writing "case" without a logical operator is the same as writing "case and". |
|||
# To make a given case act as a switch case does in other languages, use "case or". |
|||
} |
} |
||