Files
swift-mirror/test/Interpreter/if_expr.swift
Joe Groff 4c09ef61e3 Add conditional expressions.
Implement the syntax 'if x then y else z', which evaluates to 'y' if 'x' is true or 'z' if 'x' is false. 'x' must be a valid logic value, and 'y' and 'z' must be implicitly convertible to a common type.

Swift SVN r4407
2013-03-16 20:28:58 +00:00

22 lines
302 B
Swift

// RUN: %swift -i %s | FileCheck %s
// CHECK: 1
// CHECK: 2
// CHECK: fizz
// CHECK: 4
// CHECK: buzz
// CHECK: fizz
// CHECK: 7
// CHECK: 8
// CHECK: fizz
// CHECK: buzz
for i in 1..11 {
println(
if i % 3 == 0
then "fizz"
else if i % 5 == 0
then "buzz"
else
"\(i)")
}