Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Named Associated Values

enum Pizza {

  // named associated value
  case small (inches: Int)
  case medium (inches: Int)
  case large (inches: Int)
}

// pass value using provided names
var pizza1 = Pizza.medium(inches: 12)
print(pizza1)
 
PREVIOUS NEXT
Tagged: #Swift #Named #Associated #Values
ADD COMMENT
Topic
Name
2+5 =