[lang-ref] ( ternary_conditional_operator_nested ) ( swift )
@Test func ternaryConditionalOperatorNested() {
let cases: [(v: Int, expected: String)] = [
(30, "F"),
(45, "C"),
(60, "B"),
(80, "A"),
(95, "S"),
]
for (v, expected) in cases {
let rank =
v < 40 ? "F"
: v < 50 ? "C"
: v < 75 ? "B"
: v < 90 ? "A"
: "S"
#expect(rank == expected)
}
}