Search Your Question

Write program of fast enumeration in swift

Ans : 


  1. enum Beverage: CaseIterable {
  2. case coffee, tea, juice
  3. }
  4. let numberOfChoices = Beverage.allCases.count
  5. print("\(numberOfChoices) beverages available")

  1. for beverage in Beverage.allCases {
  2. print(beverage)
  3. }

2 comments:

  1. what does mean by "fast enumaration" ? can you please explain?

    ReplyDelete
    Replies
    1. for in enumerate faster than for ... . So in swift, apple called it fast enumeration way.

      Delete

Thanks