Search code examples
arraysswifterror-handlinguibezierpathswift-playground

How do I remove an item from an array that consists of functions within a class?


When I try to remove an item from the following array:

var actualFormNamesFromFormClass = [Forms.iPhoneForm, Forms.AppleForm, Forms.swiftBirdForm, Forms.watchForm, Forms.macForm]

Using the following code:

actualFormNamesFromFormClass.remove(at: i)

I get the error "Expression resolves to an unused function". My array actualFormNamesFromFormClass consists of functions that construct an array of type [UIBezierPath]. I want to remove an item from the array at index i, but I get that error. The Forms is a class and after the dot is the function in that class.


Solution

  • You can always add _ = to the start:

    _ = actualFormNamesFromFormClass.remove(at: i)
    

    since _ means "I don't need this".