fork download
  1. enum Rank: Int {
  2. case ace = 1
  3. case two, three, four, five, six, seven, eight, nine, ten
  4. case jack, queen, king
  5.  
  6. func simpleDescription() -> String {
  7. switch self {
  8. case .ace:
  9. return "ace"
  10. case .jack:
  11. return "jack"
  12. case .queen:
  13. return "queen"
  14. case .king:
  15. return "king"
  16. default:
  17. return String(self.rawValue)
  18. }
  19. }
  20. }
  21. enum Suit {
  22. case spades, hearts, diamonds, clubs
  23.  
  24. func simpleDescription() -> String {
  25. switch self {
  26. case .spades:
  27. return "spades"
  28. case .hearts:
  29. return "hearts"
  30. case .diamonds:
  31. return "diamonds"
  32. case .clubs:
  33. return "clubs"
  34. }
  35. }
  36. }
  37. struct Card {
  38. var rank: Rank
  39. var suit: Suit
  40. func simpleDescription() -> String {
  41. return "The \(rank.simpleDescription()) of \(suit.simpleDescription())"
  42. }
  43. }
  44. print(Rank.1)
Compilation error #stdin compilation error #stdout 0s 57640KB
stdin
Standard input is empty
compilation info
prog.swift:44:7: error: type 'Rank' has no member '1'
print(Rank.1)
      ^~~~ ~
<unknown>:0: error: error opening input file 'prog.o' (No such file or directory
)
clang: error: no such file or directory: 'prog.o'
clang: error: no such file or directory: '@prog.autolink'
stdout
Standard output is empty