You can use the Switch statement to match characters, as the following code demonstrates:
var grade: Character grade = "A"/*w ww .ja v a 2 s .co m*/ switch grade { case "A", "B", "C", "D": print("Passed") case "F": print("Failed") default: print("Undefined") }
The first case checks whether grade contains the character "A," "B," "C," or "D."
The second case tries to match the character "F." If all fails, the default case is matched.